Skip to content

fix(lsp): return config table from after/lsp specs (Neovim 0.12)#37

Merged
venkatarenduchintala merged 1 commit into
mainfrom
fix/after-lsp-return-table
Jul 1, 2026
Merged

fix(lsp): return config table from after/lsp specs (Neovim 0.12)#37
venkatarenduchintala merged 1 commit into
mainfrom
fix/after-lsp-return-table

Conversation

@venkatarenduchintala

Copy link
Copy Markdown
Owner

Problem

Neovim startup crashes (issue #36):

Failed to run `config` for mason-lspconfig.nvim
.../after/lsp/ansiblels.lua: not a table
  vim/lsp.lua:347 __index → vim/lsp.lua:617 enable
  → mason-lspconfig automatic_enable → mason.lua:19

On Neovim 0.12 the vim.lsp.config[name] getter re-sources after/lsp/<name>.lua and requires it to return a table. The specs used the imperative setter form vim.lsp.config('name', {...}), which returns nil — so when mason-lspconfig's automatic_enable calls vim.lsp.enable(name) (→ the getter), it throws not a table and aborts startup.

Fix

Convert all eight after/lsp/*.lua specs to the declarative return { ... } form (the documented Neovim 0.11+ native pattern). gopls, lua_ls, rust_analyzer, helm_ls, yamlls, ansiblels, jsonnet_ls, eslint.

eslint keeps its EslintFixAll-on-save autocmd, now registered under a clear = true augroup so re-sourcing during config resolution stays idempotent.

Validation

Ran against nvim v0.12.2 (the version in the report):

  • luac -p clean on all 8 files.
  • Each file now returns a table with its settings (and jsonnet_ls its cmd).
  • vim.lsp.config[name] — the exact failing frame — resolves for all 8 servers with settings merged, no throw (previously threw for ansiblels).

Fixes #36.

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.
@venkatarenduchintala venkatarenduchintala merged commit d1e114e into main Jul 1, 2026
2 checks passed
@venkatarenduchintala venkatarenduchintala deleted the fix/after-lsp-return-table branch July 1, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to run config for mason-lspconfig.nvim

1 participant