aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cbfmt.toml3
-rw-r--r--.github/workflows/cbfmt.yml33
-rw-r--r--CONTRIBUTING.md32
-rw-r--r--doc/reference.md20
4 files changed, 64 insertions, 24 deletions
diff --git a/.cbfmt.toml b/.cbfmt.toml
new file mode 100644
index 00000000..7e9f6a7d
--- /dev/null
+++ b/.cbfmt.toml
@@ -0,0 +1,3 @@
+[languages]
+lua = ["stylua -s -"]
+sh = ["shellharden --transform "]
diff --git a/.github/workflows/cbfmt.yml b/.github/workflows/cbfmt.yml
new file mode 100644
index 00000000..d9a5e2d9
--- /dev/null
+++ b/.github/workflows/cbfmt.yml
@@ -0,0 +1,33 @@
+name: cbfmt check
+
+on:
+ push:
+ branches:
+ - "main"
+ pull_request:
+
+jobs:
+ cbfmt:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Download cbfmt
+ run: |
+ mkdir /tmp/cbfmt && cd $_
+ curl -fsSL -o cbfmt.tar.gz "https://github.com/lukas-reineke/cbfmt/releases/download/v0.1.4/cbfmt_linux-x86_64_v0.1.4.tar.gz"
+ tar --strip-components 1 -xvf cbfmt.tar.gz
+ mv cbfmt /usr/local/bin/
+ - name: Download Stylua
+ run: |
+ mkdir /tmp/stylua && cd $_
+ curl -fsSL -o stylua.zip "https://github.com/JohnnyMorganz/StyLua/releases/download/v0.14.2/stylua-linux.zip"
+ unzip -d /usr/local/bin stylua.zip
+ - name: Download Shellharden
+ run: |
+ mkdir /tmp/shellharden && cd $_
+ curl -fsSL -o shellharden.tar.gz https://github.com/alsuren/cargo-quickinstall/releases/download/shellharden-4.2.0-x86_64-unknown-linux-gnu/shellharden-4.2.0-x86_64-unknown-linux-gnu.tar.gz
+ tar -xvf shellharden.tar.gz
+ mv shellharden /usr/local/bin/
+ - name: Run cbfmt check
+ # Lua examples in README.md doesn't conform to Stylua rules, on purpose.
+ run: find . -name '*.md' -not -path './dependencies/*' -not -path './README.md' | xargs cbfmt --check
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b3353079..227de6c7 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,13 +1,17 @@
-- [Contribution policy](#contribution-policy)
-- [Adding a new package](#adding-a-new-package)
- - [The anatomy of a package](#the-anatomy-of-a-package)
- - [Package name](#package-name)
- - [Package homepage](#package-homepage)
- - [Package categories](#package-categories)
- - [Package languages](#package-languages)
- - [Package installer](#package-installer)
-- [Code style](#code-style)
-- [Generated code](#generated-code)
+- [Contribution policy](#contribution-policy)
+- [Adding a new package](#adding-a-new-package)
+ - [The anatomy of a package](#the-anatomy-of-a-package)
+ - [Package name](#package-name)
+ - [Package homepage](#package-homepage)
+ - [Package categories](#package-categories)
+ - [Package languages](#package-languages)
+ - [Package installer](#package-installer)
+- [Code style](#code-style)
+- [Generated code](#generated-code)
+- [Tests](#tests)
+- [Adding or changing a feature](#adding-or-changing-a-feature)
+- [Commit style](#commit-style)
+- [Pull requests](#pull-requests)
# Contribution policy
@@ -93,7 +97,7 @@ generated and pushed to your branch before merge.
Generating code can be done on Unix systems like so:
```sh
-$ make generate
+make generate
```
# Tests
@@ -102,9 +106,9 @@ $ make generate
Tests can be executed on Unix systems like so:
```sh
-$ make test
-$ FILE=tests/mason-core/managers/luarocks_spec.lua make test
-````
+make test
+FILE=tests/mason-core/managers/luarocks_spec.lua make test
+```
# Adding or changing a feature
diff --git a/doc/reference.md b/doc/reference.md
index c16f2e0e..245cde7a 100644
--- a/doc/reference.md
+++ b/doc/reference.md
@@ -99,10 +99,10 @@ Metatable used to declare language identifiers. Any key is valid and will be aut
example:
```lua
- print(vim.inspect(Package.Lang)) -- prints {}
- local lang = Package.Lang.SomeMadeUpLanguage
- print(lang) -- prints "SomeMadeUpLanguage"
- print(vim.inspect(Package.Lang)) -- prints { SomeMadeUpLanguage = "SomeMadeUpLanguage" }
+print(vim.inspect(Package.Lang)) -- prints {}
+local lang = Package.Lang.SomeMadeUpLanguage
+print(lang) -- prints "SomeMadeUpLanguage"
+print(vim.inspect(Package.Lang)) -- prints { SomeMadeUpLanguage = "SomeMadeUpLanguage" }
```
### `Package.Cat`
@@ -110,7 +110,7 @@ example:
**Type:**
```lua
-{
+Package.Cat = {
Compiler = "Compiler",
Runtime = "Runtime",
DAP = "DAP",
@@ -228,10 +228,10 @@ Pkg.new {
--- ...
---@async
---@param ctx InstallContext
- install = function (ctx)
+ install = function(ctx)
ctx.stdio_sink.stdout "I am doing stuff\n"
ctx.stdio_sink.stderr "Something went wrong!\n"
- end
+ end,
}
```
@@ -255,13 +255,13 @@ Pkg.new {
--- ...
---@async
---@param ctx InstallContext
- install = function (ctx)
+ install = function(ctx)
ctx.spawn.npm { "install", "some-package" }
-- Calls to spawn will raise an error if it exits with a non-OK exit code or signal.
- pcall(function ()
+ pcall(function()
ctx.spawn.commandoesntexist {}
end)
- end
+ end,
}
```