aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-09-13 14:14:22 +0200
committerGitHub <noreply@github.com>2022-09-13 14:14:22 +0200
commit2ca0caadbe9117cb295edda6aa3c03e354f2c3c1 (patch)
tree2d855881b174cfa9dfbaca4890d899b052216597
parentchore: update generated code (#53) (diff)
downloadmason-lspconfig-2ca0caadbe9117cb295edda6aa3c03e354f2c3c1.tar
mason-lspconfig-2ca0caadbe9117cb295edda6aa3c03e354f2c3c1.tar.gz
mason-lspconfig-2ca0caadbe9117cb295edda6aa3c03e354f2c3c1.tar.bz2
mason-lspconfig-2ca0caadbe9117cb295edda6aa3c03e354f2c3c1.tar.lz
mason-lspconfig-2ca0caadbe9117cb295edda6aa3c03e354f2c3c1.tar.xz
mason-lspconfig-2ca0caadbe9117cb295edda6aa3c03e354f2c3c1.tar.zst
mason-lspconfig-2ca0caadbe9117cb295edda6aa3c03e354f2c3c1.zip
chore: add selene & cbfmt (#54)
-rw-r--r--.cbfmt.toml3
-rw-r--r--.github/workflows/cbfmt.yml33
-rw-r--r--.github/workflows/selene.yml20
-rw-r--r--lua/mason-lspconfig/api/command.lua1
-rw-r--r--lua/mason-lspconfig/server_configurations/julials/init.lua11
-rw-r--r--lua/mason-lspconfig/server_configurations/omnisharp/README.md2
-rw-r--r--scripts/lua/mason-scripts/mason-lspconfig/generate.lua3
-rw-r--r--selene.toml5
-rw-r--r--tests/helpers/lua/test_helpers.lua1
-rw-r--r--tests/mason-lspconfig/api/api_spec.lua2
-rw-r--r--vim.yml67
11 files changed, 139 insertions, 9 deletions
diff --git a/.cbfmt.toml b/.cbfmt.toml
new file mode 100644
index 0000000..7e9f6a7
--- /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 0000000..d9a5e2d
--- /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/.github/workflows/selene.yml b/.github/workflows/selene.yml
new file mode 100644
index 0000000..7ce7ba8
--- /dev/null
+++ b/.github/workflows/selene.yml
@@ -0,0 +1,20 @@
+name: Selene check
+
+on:
+ push:
+ branches:
+ - "main"
+ pull_request:
+
+jobs:
+ selene:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Run Selene check
+ uses: NTBBloodbath/selene-action@v1.0.0
+ with:
+ # token is needed because the action allegedly downloads binary from github releases
+ token: ${{ secrets.GITHUB_TOKEN }}
+ args: lua/ tests/ scripts/
+ version: 0.20.0
diff --git a/lua/mason-lspconfig/api/command.lua b/lua/mason-lspconfig/api/command.lua
index ba44b4f..9f58797 100644
--- a/lua/mason-lspconfig/api/command.lua
+++ b/lua/mason-lspconfig/api/command.lua
@@ -133,6 +133,7 @@ end, {
complete = "custom,v:lua.mason_lspconfig_completion.installed_server_completion",
})
+-- selene: allow(global_usage)
_G.mason_lspconfig_completion = {
available_server_completion = function()
local available_servers = require("mason-lspconfig").get_available_servers()
diff --git a/lua/mason-lspconfig/server_configurations/julials/init.lua b/lua/mason-lspconfig/server_configurations/julials/init.lua
index e5bc6c4..d2802d5 100644
--- a/lua/mason-lspconfig/server_configurations/julials/init.lua
+++ b/lua/mason-lspconfig/server_configurations/julials/init.lua
@@ -1,18 +1,17 @@
local path = require "mason-core.path"
-local platform = require "mason-core.platform"
local fs = require "mason-core.fs"
local _ = require "mason-core.functional"
----@param install_dir string
-return function(install_dir)
+return function()
return {
on_new_config = function(config, workspace_dir)
local env_path = config.julia_env_path and vim.fn.expand(config.julia_env_path)
if not env_path then
local file_exists = _.compose(fs.sync.file_exists, path.concat, _.concat { workspace_dir })
- if file_exists { "Project.toml" } and file_exists { "Manifest.toml" } then
- env_path = workspace_dir
- elseif file_exists { "JuliaProject.toml" } and file_exists { "JuliaManifest.toml" } then
+ if
+ (file_exists { "Project.toml" } and file_exists { "Manifest.toml" })
+ or (file_exists { "JuliaProject.toml" } and file_exists { "JuliaManifest.toml" })
+ then
env_path = workspace_dir
end
end
diff --git a/lua/mason-lspconfig/server_configurations/omnisharp/README.md b/lua/mason-lspconfig/server_configurations/omnisharp/README.md
index 2b7e601..f74344e 100644
--- a/lua/mason-lspconfig/server_configurations/omnisharp/README.md
+++ b/lua/mason-lspconfig/server_configurations/omnisharp/README.md
@@ -9,7 +9,7 @@ use the `omnisharp_mono` server instead (**this requires the `omnisharp-mono` pa
This is done in order to separate the .NET and Mono variants, making both easily accessible.
```lua
-local lspconfig = require("lspconfig")
+local lspconfig = require "lspconfig"
lspconfig.omnisharp_mono.setup {}
```
diff --git a/scripts/lua/mason-scripts/mason-lspconfig/generate.lua b/scripts/lua/mason-scripts/mason-lspconfig/generate.lua
index 464de50..c539d4d 100644
--- a/scripts/lua/mason-scripts/mason-lspconfig/generate.lua
+++ b/scripts/lua/mason-scripts/mason-lspconfig/generate.lua
@@ -53,7 +53,8 @@ local function create_server_mapping_docs()
local table_body = _.compose(
_.filter_map(function(pair)
- local lspconfig_name, mason_name = assert(pair[1]), assert(pair[2])
+ local lspconfig_name, mason_name =
+ assert(pair[1], "missing lspconfig name"), assert(pair[2], "missing mason name")
if not pcall(require, ("lspconfig.server_configurations.%s"):format(lspconfig_name)) then
return Optional.empty()
end
diff --git a/selene.toml b/selene.toml
new file mode 100644
index 0000000..d8e213a
--- /dev/null
+++ b/selene.toml
@@ -0,0 +1,5 @@
+std="lua51+vim"
+
+[rules]
+unused_variable = "allow"
+shadowing = "allow"
diff --git a/tests/helpers/lua/test_helpers.lua b/tests/helpers/lua/test_helpers.lua
index 57c0b4f..1880c39 100644
--- a/tests/helpers/lua/test_helpers.lua
+++ b/tests/helpers/lua/test_helpers.lua
@@ -16,6 +16,7 @@ function async_test(suspend_fn)
end
end
+-- selene: allow(incorrect_standard_library_use)
mockx = {
just_runs = function() end,
returns = function(val)
diff --git a/tests/mason-lspconfig/api/api_spec.lua b/tests/mason-lspconfig/api/api_spec.lua
index e4f398d..01a4d13 100644
--- a/tests/mason-lspconfig/api/api_spec.lua
+++ b/tests/mason-lspconfig/api/api_spec.lua
@@ -5,7 +5,7 @@ describe("mason-lspconfig API", function()
it("should return all available servers", function()
local server_mappings = require "mason-lspconfig.mappings.server"
local available_servers = mason_lspconfig.get_available_servers()
- assert.equal(#vim.tbl_keys(server_mappings.package_to_lspconfig), #available_servers)
+ assert.equals(#vim.tbl_keys(server_mappings.package_to_lspconfig), #available_servers)
end)
it("should return all available servers for given filetype", function()
diff --git a/vim.yml b/vim.yml
new file mode 100644
index 0000000..72b86e7
--- /dev/null
+++ b/vim.yml
@@ -0,0 +1,67 @@
+---
+globals:
+ jit.os:
+ type: string
+ property: read-only
+ package.config:
+ type: string
+ property: read-only
+ vim:
+ any: true
+ async_test:
+ args:
+ - type: function
+ assert.wait_for:
+ args:
+ - type: function
+ InstallHandleGenerator:
+ args:
+ - type: string
+ InstallContextGenerator:
+ args:
+ - type: any
+ - type: table
+ required: false
+ mockx.throws:
+ args:
+ - type: any
+ required: false
+ mockx.just_runs:
+ args: []
+ mockx.returns:
+ args:
+ - type: any
+
+ describe:
+ args:
+ - type: string
+ - type: function
+ before_each:
+ args:
+ - type: function
+ it:
+ args:
+ - type: string
+ - type: function
+ assert.equals:
+ args:
+ - type: any
+ - type: any
+ assert.same:
+ args:
+ - type: any
+ - type: any
+ assert.is_true:
+ args:
+ - type: any
+ assert.is_false:
+ args:
+ - type: any
+ assert.has_error:
+ args:
+ - type: function
+ assert.is_nil:
+ args:
+ - type: any
+ assert.spy:
+ any: true