Skip to content

fix(lsp): migrate to vim.lsp.config and clear startup crash#2053

Closed
tmas333 wants to merge 12 commits into
nvim-lua:masterfrom
tmas333:fix/lsp-migrate-0.11-api
Closed

fix(lsp): migrate to vim.lsp.config and clear startup crash#2053
tmas333 wants to merge 12 commits into
nvim-lua:masterfrom
tmas333:fix/lsp-migrate-0.11-api

Conversation

@tmas333
Copy link
Copy Markdown

@tmas333 tmas333 commented May 16, 2026

Summary

Neovim was crashing on startup with a stack trace ending at init.lua:664, and two LSP clients (stylua, Copilot) were dying every session. This PR fixes the crash and the spurious stylua LSP client, and bundles accumulated plugin work that had been lingering in the working tree.

What was broken

  • require('lspconfig').<server>.setup() is deprecated on nvim 0.11 and will be removed in nvim-lspconfig v3.0.0. The framework's __index was already raising on .ruff / .basedpyright, producing the stack trace.
  • nvim-lspconfig now ships a community lsp/stylua.lua definition. The old mason-lspconfig handlers block was iterating over every mason-installed package whose name matched a known lspconfig server — so the stylua formatter was being launched as an LSP server with --lsp, exiting 2 every startup.
  • The third error (Copilot: Process exited with status 243) is an npm cache permission issue on the local machine (EACCES on ~/.npm/_npx/...). Not a config bug — see verification notes below.

What this PR does

Commit 1 — fix(lsp) (init.lua only)

  • Replaces the deprecated require('lspconfig').xxx.setup(...) pattern with native 0.11 API: vim.lsp.config(name, cfg) + vim.lsp.enable(name).
  • Folds ruff and basedpyright into the main servers table so they get the blink.cmp capability merge and Mason auto-install like everything else.
  • Drops mason-lspconfig.setup { handlers = ... } entirely. With handlers gone, only names explicitly handed to vim.lsp.enable are ever launched — stylua cannot be mis-started as an LSP again. It stays in mason-tool-installer's list as a formatter for conform.nvim.

Commit 2 — chore(plugins) (everything else that was sitting in the working tree)

  • New: code_companion, golf, neotest (rustaceanvim adapter), nvim-bacon, vim-pencil, quickscope.
  • Modified: rustaceanvim^6 with clippy/rustfmt config + neotest dep; obsidian checkbox order; trouble keymaps reworked (<leader>xx<leader>xd, add <leader>xl sidebar toggle).
  • Deleted: cyberdream (tokyonight is the active colorscheme now).

Test plan

  • Out-of-band first: sudo chown -R 501:20 ~/.npm — fixes the Copilot 243 error (root-owned files in ~/.npm/_npx/). This is system state, not in the diff.
  • nvim from $HOME — no stack trace, no deprecation warning, no Client stylua quit notification.
  • Open a .lua file → :LspInfo shows lua_ls attached and no stylua client.
  • Open a .py file → :LspInfo shows both ruff and basedpyright.
  • Open .tf, ansible .yml, plain .yaml → corresponding server attaches.
  • <leader>f on a Lua file still formats via stylua (through conform.nvim).
  • :Mason lists ruff, basedpyright, stylua, lua-language-server, terraform-ls, tflint, ansible-language-server, yaml-language-server all installed.
  • :checkhealth lsp clean.
  • After the chown, :CopilotChat opens without spawning a 243 exit, and ~/.local/state/nvim/lsp.log shows no new stylua --lsp or EACCES errors.

🤖 Generated with Claude Code

tmas333 added 12 commits April 20, 2025 09:07
Opening Neovim crashed at init.lua:664 because nvim-lspconfig's
require('lspconfig').<server>.setup() framework is deprecated on
nvim 0.11 and slated for removal in v3.0.0. The same lspconfig
update ships a community lsp/stylua.lua, so the mason-lspconfig
handler was launching the stylua formatter with --lsp and getting
exit code 2 on every startup.

Replace the lspconfig + mason-lspconfig handler path with the
native 0.11 API: register each server via vim.lsp.config() and
activate via vim.lsp.enable(). Fold ruff and basedpyright into the
servers table so they share the blink.cmp capability merge and
mason auto-install. Stylua stays in the mason-tool-installer list
for conform.nvim to consume; nothing ever enables it as an LSP.
Bundle accumulated plugin work that had been sitting in the working
tree: add CodeCompanion, golf, neotest (with rustaceanvim adapter),
nvim-bacon, vim-pencil, and quickscope; bump rustaceanvim to ^6 with
clippy/rustfmt settings and a neotest dependency; add an Obsidian
checkbox order; rework trouble keymaps to free <leader>xx and add a
sidebar diagnostic toggle. Drop cyberdream — tokyonight is the
current colorscheme.
@tmas333
Copy link
Copy Markdown
Author

tmas333 commented May 16, 2026

Closing — opened against upstream by mistake, this should target my fork. Sorry for the noise.

@tmas333 tmas333 closed this May 16, 2026
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.

1 participant