nvim/lsp: allow setting all lsp config field in user config

This commit is contained in:
Primrose 2025-07-19 12:18:29 +02:00
parent c8fd1b4163
commit ead40c844d
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -20,8 +20,10 @@ local servers = {
-- golangci_lint_ls = {},
tinymist = {},
nil_ls = {
settings = {
["nil"] = { formatting = { command = { "alejandra" } } },
},
},
}
vim.diagnostic.config {
@ -55,10 +57,13 @@ vim.lsp.set_log_level("off")
-- It is not recommended to break lspconfig into different settings
-- related: https://github.com/neovim/nvim-lspconfig/issues/970#issuecomment-860080502
for name, config in pairs(servers) do
require("lspconfig")[name].setup {
for name, user_config in pairs(servers) do
local default_config = {
capabilities = mylsp.capabilities,
settings = config,
settings = user_config,
on_attach = function(client, bufno) mylsp.on_attach(client, bufno) end,
}
local merged_config = vim.tbl_deep_extend("force", default_config, user_config)
require("lspconfig")[name].setup(merged_config)
end