Skip to content

Commit 778cca0

Browse files
author
Venkata Subramani Renduchintala
committed
fix(lsp): return config table from after/lsp specs (Neovim 0.12)
On Neovim 0.12 the `vim.lsp.config[name]` getter re-sources after/lsp/<name>.lua and requires it to RETURN a table. The files used the imperative setter form `vim.lsp.config('name', {...})` (which returns nil), so mason-lspconfig automatic_enable -> vim.lsp.enable -> vim.lsp.config[name] threw ".../after/lsp/ansiblels.lua: not a table" and aborted startup. Convert all eight after/lsp specs to the declarative `return { ... }` form. eslint keeps its EslintFixAll-on-save autocmd, now registered under a clear=true augroup so re-sourcing during config resolution stays idempotent. Fixes #36.
1 parent 46b0131 commit 778cca0

8 files changed

Lines changed: 26 additions & 21 deletions

File tree

after/lsp/ansiblels.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim.lsp.config('ansiblels', {
1+
return {
22
settings = {
33
ansible = {
44
ansible = {
@@ -19,4 +19,4 @@ vim.lsp.config('ansiblels', {
1919
},
2020
},
2121
},
22-
})
22+
}

after/lsp/eslint.lua

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
vim.lsp.config('eslint', {
2-
settings = {
3-
packageManager = "npm",
4-
},
5-
})
6-
7-
-- EslintFixAll on save, scoped to eslint-attached buffers only
1+
-- EslintFixAll on save, scoped to eslint-attached buffers only.
2+
-- Registered as a side effect when this config file is sourced; the augroup's
3+
-- clear = true keeps it idempotent if the file is sourced more than once.
4+
local group = vim.api.nvim_create_augroup("EslintFixOnSave", { clear = true })
85
vim.api.nvim_create_autocmd("LspAttach", {
6+
group = group,
97
callback = function(args)
108
local client = vim.lsp.get_client_by_id(args.data.client_id)
119
if client and client.name == "eslint" then
@@ -16,3 +14,9 @@ vim.api.nvim_create_autocmd("LspAttach", {
1614
end
1715
end,
1816
})
17+
18+
return {
19+
settings = {
20+
packageManager = "npm",
21+
},
22+
}

after/lsp/gopls.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
vim.lsp.config('gopls', {
1+
-- Merged into the gopls config resolved by vim.lsp (Neovim 0.11+ native API).
2+
return {
23
settings = {
34
gopls = {
45
analyses = {
@@ -9,4 +10,4 @@ vim.lsp.config('gopls', {
910
gofumpt = true,
1011
},
1112
},
12-
})
13+
}

after/lsp/helm_ls.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim.lsp.config('helm_ls', {
1+
return {
22
settings = {
33
['helm-ls'] = {
44
logLevel = "info",
@@ -22,4 +22,4 @@ vim.lsp.config('helm_ls', {
2222
},
2323
},
2424
},
25-
})
25+
}

after/lsp/jsonnet_ls.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim.lsp.config('jsonnet_ls', {
1+
return {
22
cmd = { "jsonnet-language-server", "-t" },
33
settings = {
44
ext_vars = {},
@@ -11,4 +11,4 @@ vim.lsp.config('jsonnet_ls', {
1111
SortImports = true,
1212
},
1313
},
14-
})
14+
}

after/lsp/lua_ls.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim.lsp.config('lua_ls', {
1+
return {
22
settings = {
33
Lua = {
44
runtime = { version = "LuaJIT" },
@@ -7,4 +7,4 @@ vim.lsp.config('lua_ls', {
77
telemetry = { enable = false },
88
},
99
},
10-
})
10+
}

after/lsp/rust_analyzer.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim.lsp.config('rust_analyzer', {
1+
return {
22
settings = {
33
["rust-analyzer"] = {
44
diagnostics = { enable = true },
@@ -10,4 +10,4 @@ vim.lsp.config('rust_analyzer', {
1010
procMacro = { enable = true },
1111
},
1212
},
13-
})
13+
}

after/lsp/yamlls.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vim.lsp.config('yamlls', {
1+
return {
22
settings = {
33
yaml = {
44
validate = true,
@@ -20,4 +20,4 @@ vim.lsp.config('yamlls', {
2020
},
2121
},
2222
},
23-
})
23+
}

0 commit comments

Comments
 (0)