Skip to content

Commit

Permalink
fix: merge user customized config with predefined. (#1376)
Browse files Browse the repository at this point in the history
* fix: merge user customized config with predefined.

* fix: overwrite predefined config only when both are table.
  • Loading branch information
ayamir authored Dec 12, 2024
1 parent 38c3ee4 commit 42ce15d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lua/modules/configs/completion/mason-lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,19 @@ please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` dire
end

local ok, custom_handler = pcall(require, "user.configs.lsp-servers." .. lsp_name)
local predefined_ok, predefined = pcall(require, "completion.servers." .. lsp_name)
-- Use preset if there is no user definition
if not ok then
ok, custom_handler = pcall(require, "completion.servers." .. lsp_name)
ok, custom_handler = predefined_ok, predefined
else
if type(custom_handler) == "table" and type(predefined) == "table" then
custom_handler = vim.tbl_deep_extend("force", predefined, custom_handler)
end
end

if not ok then
-- Default to use factory config for server(s) that doesn't include a spec
nvim_lsp[lsp_name].setup(opts)
return
elseif type(custom_handler) == "function" then
--- Case where language server requires its own setup
--- Make sure to call require("lspconfig")[lsp_name].setup() in the function
Expand Down

0 comments on commit 42ce15d

Please sign in to comment.