From ead40c844d558e40990ef86cce18466185741a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Sat, 19 Jul 2025 12:18:29 +0200 Subject: [PATCH] nvim/lsp: allow setting all lsp config field in user config --- .config/nvim/plugin/lsp.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.config/nvim/plugin/lsp.lua b/.config/nvim/plugin/lsp.lua index c17ce4f0..9e5466b8 100644 --- a/.config/nvim/plugin/lsp.lua +++ b/.config/nvim/plugin/lsp.lua @@ -20,7 +20,9 @@ local servers = { -- golangci_lint_ls = {}, tinymist = {}, nil_ls = { - ["nil"] = { formatting = { command = { "alejandra" } } }, + settings = { + ["nil"] = { formatting = { command = { "alejandra" } } }, + }, }, } @@ -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