Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: merge user customized config with predefined. #1376

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading