fix(lsp): return config table from after/lsp specs (Neovim 0.12)#37
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Neovim startup crashes (issue #36):
On Neovim 0.12 the
vim.lsp.config[name]getter re-sourcesafter/lsp/<name>.luaand requires it to return a table. The specs used the imperative setter formvim.lsp.config('name', {...}), which returnsnil— so whenmason-lspconfig'sautomatic_enablecallsvim.lsp.enable(name)(→ the getter), it throwsnot a tableand aborts startup.Fix
Convert all eight
after/lsp/*.luaspecs to the declarativereturn { ... }form (the documented Neovim 0.11+ native pattern).gopls,lua_ls,rust_analyzer,helm_ls,yamlls,ansiblels,jsonnet_ls,eslint.eslintkeeps itsEslintFixAll-on-save autocmd, now registered under aclear = trueaugroup so re-sourcing during config resolution stays idempotent.Validation
Ran against nvim v0.12.2 (the version in the report):
luac -pclean on all 8 files.settings(andjsonnet_lsitscmd).vim.lsp.config[name]— the exact failing frame — resolves for all 8 servers with settings merged, no throw (previously threw foransiblels).Fixes #36.