nvim lspconfig deprecation fix

This commit is contained in:
Henrik Bakken
2025-09-18 11:51:54 +02:00
parent c88cb8d559
commit 32016780c4
+32 -50
View File
@@ -380,6 +380,20 @@ local function makespecs_themes()
end end
local function makespec_lspconfig() local function makespec_lspconfig()
local rootdirfix = function(root_markers)
return function(bufnr, on_dir)
on_dir(require("lspconfig").util.root_pattern(unpack(root_markers))(vim.fn.bufname(bufnr)))
end
end
local pyroot = {
".git",
"pyproject.toml",
"setup.py",
"setup.cfg",
"requirements.txt",
"Pipfile",
"pyrightconfig.json",
}
return { return {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
lazy = false, lazy = false,
@@ -387,11 +401,7 @@ local function makespec_lspconfig()
cmd = { "LspInfo", "LspRestart", "LspStart", "LspStop" }, cmd = { "LspInfo", "LspRestart", "LspStart", "LspStop" },
keys = { { "<F4>", "<cmd>LspInfo<cr>", noremap = true } }, keys = { { "<F4>", "<cmd>LspInfo<cr>", noremap = true } },
config = function() config = function()
local lspconfig = require("lspconfig") vim.lsp.config("lua_ls", {
lspconfig.tinymist.setup({})
lspconfig.bashls.setup({})
lspconfig.nushell.setup({})
lspconfig.lua_ls.setup({
cmd = { "lua-language-server" }, cmd = { "lua-language-server" },
settings = { settings = {
Lua = { Lua = {
@@ -406,7 +416,7 @@ local function makespec_lspconfig()
}, },
}, },
}) })
lspconfig.clangd.setup({ vim.lsp.config("clangd", {
cmd = { cmd = {
"clangd", "clangd",
"--background-index", "--background-index",
@@ -418,7 +428,7 @@ local function makespec_lspconfig()
}, },
filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" }, filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
}) })
lspconfig.html.setup({ vim.lsp.config("html", {
cmd = { "vscode-html-language-server", "--stdio" }, cmd = { "vscode-html-language-server", "--stdio" },
settings = { settings = {
html = { html = {
@@ -431,7 +441,7 @@ local function makespec_lspconfig()
}, },
}, },
}) })
lspconfig.yamlls.setup({ vim.lsp.config("yamlls", {
settings = { settings = {
yaml = { yaml = {
schemas = { kubernetes = "/home/hjalmarlucius/src/hjarl/system/manifests/*.yaml" }, schemas = { kubernetes = "/home/hjalmarlucius/src/hjarl/system/manifests/*.yaml" },
@@ -439,49 +449,10 @@ local function makespec_lspconfig()
}, },
}, },
}) })
lspconfig.pylsp.setup({ vim.lsp.config("basedpyright", {
filetypes = { "python" },
root_dir = function(fname)
local root_files = {
".git",
"pyproject.toml",
"setup.py",
"setup.cfg",
"requirements.txt",
"Pipfile",
"pyrightconfig.json",
}
return lspconfig.util.root_pattern(unpack(root_files))(fname)
end,
settings = {
pylsp = {
plugins = {
pylsp_mypy = {
enabled = true,
dmypy = true,
},
pycodestyle = { enabled = false },
mccabe = { enabled = false },
},
},
},
-- Other lspconfig options like on_attach, capabilities can be set here
})
lspconfig.basedpyright.setup({
cmd = { "basedpyright-langserver", "--stdio", "--threads", "20" }, cmd = { "basedpyright-langserver", "--stdio", "--threads", "20" },
filetypes = { "python" }, filetypes = { "python" },
root_dir = function(fname) root_dir = rootdirfix(pyroot),
local root_files = {
".git",
"pyproject.toml",
"setup.py",
"setup.cfg",
"requirements.txt",
"Pipfile",
"pyrightconfig.json",
}
return lspconfig.util.root_pattern(unpack(root_files))(fname)
end,
settings = { settings = {
python = { python = {
analysis = { analysis = {
@@ -494,7 +465,7 @@ local function makespec_lspconfig()
}, },
}, },
}) })
lspconfig.vtsls.setup({ vim.lsp.config("vtsls", {
settings = { settings = {
complete_function_calls = true, complete_function_calls = true,
vtsls = { vtsls = {
@@ -537,6 +508,17 @@ local function makespec_lspconfig()
}, },
}, },
}) })
vim.lsp.enable("bashls")
vim.lsp.enable("clangd")
vim.lsp.enable("html")
vim.lsp.enable("lua_ls")
vim.lsp.enable("nushell")
vim.lsp.enable("pylsp")
vim.lsp.enable("basedpyright")
vim.lsp.enable("tinymist")
vim.lsp.enable("vtsls")
vim.lsp.enable("yamlls")
end, end,
} }
end end