fix(neovim): migrate LSP config to native vim.lsp.config API

Replace deprecated require("lspconfig") setup with the Neovim 0.11+
native vim.lsp.config/vim.lsp.enable API. Clangd config now lives in
lsp/clangd.lua instead of the old plugins/lspconfig.lua +
configs/lspconfig.lua pair.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
marvin.dietermann
2026-04-10 15:02:01 +02:00
parent d1286329f8
commit 7021c915e6
2 changed files with 27 additions and 42 deletions

View File

@@ -298,15 +298,10 @@ return {
} }
``` ```
Create `~/.config/nvim/lua/plugins/lsp.lua`: Create `~/.config/nvim/lsp/clangd.lua` (native Neovim 0.11+ LSP config):
```lua ```lua
return { return {
{
"neovim/nvim-lspconfig",
opts = {
servers = {
clangd = {
cmd = { cmd = {
"clangd", "clangd",
"--background-index", "--background-index",
@@ -314,13 +309,16 @@ return {
"--header-insertion=iwyu", "--header-insertion=iwyu",
"--completion-style=detailed", "--completion-style=detailed",
}, },
}, filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "arduino" },
},
},
},
} }
``` ```
Enable the server (e.g. in `init.lua` or a plugin file):
```lua
vim.lsp.enable("clangd")
```
--- ---
## 5. Arduino CLI ## 5. Arduino CLI

View File

@@ -143,34 +143,11 @@ return {
} }
LUA LUA
# ── LSP (clangd) ─────────────────────────────────────────────── # ── LSP (clangd) — native vim.lsp.config (Neovim 0.11+) ──────
mkdir -p "$NVIM_CFG/lua/configs" mkdir -p "$NVIM_CFG/lsp"
cat >"$NVIM_CFG/lua/plugins/lspconfig.lua" <<'LUA' cat >"$NVIM_CFG/lsp/clangd.lua" <<'LUA'
return { return {
{
"neovim/nvim-lspconfig",
config = function()
require("nvchad.configs.lspconfig").defaults()
require "configs.lspconfig"
end,
},
}
LUA
cat >"$NVIM_CFG/lua/configs/lspconfig.lua" <<'LUA'
local configs = require "nvchad.configs.lspconfig"
local on_attach = configs.on_attach
local on_init = configs.on_init
local capabilities = configs.capabilities
local lspconfig = require "lspconfig"
lspconfig.clangd.setup {
on_init = on_init,
on_attach = on_attach,
capabilities = capabilities,
cmd = { cmd = {
"clangd", "clangd",
"--background-index", "--background-index",
@@ -178,9 +155,19 @@ lspconfig.clangd.setup {
"--header-insertion=iwyu", "--header-insertion=iwyu",
"--completion-style=detailed", "--completion-style=detailed",
}, },
filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "arduino" },
} }
LUA LUA
# Enable clangd via native API
cat >"$NVIM_CFG/lua/plugins/lspconfig.lua" <<'LUA'
vim.lsp.enable("clangd")
return {}
LUA
# Clean up legacy configs/lspconfig.lua if present
rm -f "$NVIM_CFG/lua/configs/lspconfig.lua"
# ── Keymaps ───────────────────────────────────────────────────── # ── Keymaps ─────────────────────────────────────────────────────
cat >"$NVIM_CFG/lua/mappings.lua" <<'LUA' cat >"$NVIM_CFG/lua/mappings.lua" <<'LUA'
require "nvchad.mappings" require "nvchad.mappings"