Skip to content

Commit

Permalink
fix: avoid mutating global lsp opts when using custom server opts
Browse files Browse the repository at this point in the history
  • Loading branch information
brunohcastro authored Dec 11, 2022
1 parent e9295be commit d80da22
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lua/config/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ import({ "mason", "mason-lspconfig", "lspconfig", "cmp_nvim_lsp" }, function(mod
function(server_name)
local has_custom_opts, custom_opts = pcall(require, "config.lsp.settings." .. server_name)

local server_opts = opts

if has_custom_opts then
opts = vim.tbl_deep_extend("force", custom_opts, opts)
server_opts = vim.tbl_deep_extend("force", custom_opts, opts)
end

modules.lspconfig[server_name].setup(opts)
modules.lspconfig[server_name].setup(server_opts)
end,
["tsserver"] = function()
import("typescript", function(typescript)
Expand Down

0 comments on commit d80da22

Please sign in to comment.