fix(lspconfig): dont deepcopy the full config. Do settings only

This commit is contained in:
Folke Lemaitre 2023-09-28 17:07:56 +02:00
parent 062f85faa8
commit 37a7205282
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 6 additions and 9 deletions

View File

@ -41,7 +41,7 @@ function M.on_new_config(config, root_dir, original_config)
end
-- backup original lsp config
config.original_config = vim.deepcopy(original_config)
config.original_settings = vim.deepcopy(original_config.settings or {})
root_dir = require("neoconf.workspace").find_root({ file = root_dir })
local enabled = Settings.get_local(root_dir):get("lspconfig." .. config.name, { expand = true })
@ -74,26 +74,23 @@ function M.on_update(fname)
-- reload this client if the global file changed, or its root dir equals the local one
if is_global or Util.has_file(settings_root, client.config.root_dir) then
local old_config = vim.deepcopy(client.config.settings)
local old_settings = vim.deepcopy(client.config.settings)
-- retrieve new settings only
local new_config = vim.deepcopy(client.config.original_config or {})
client.config.settings = vim.deepcopy(client.config.original_settings or {})
local document_config = Util.has_lspconfig(client.name) and require("lspconfig")[client.name].document_config
-- re-apply config from any other plugins that were overriding on_new_config
if document_config and document_config.on_new_config then
pcall(document_config.on_new_config, new_config, client.config.root_dir)
pcall(document_config.on_new_config, client.config, client.config.root_dir)
end
if client.config.on_new_config then
pcall(client.config.on_new_config, new_config, client.config.root_dir)
pcall(client.config.on_new_config, client.config, client.config.root_dir)
end
-- only keep the settings
client.config.settings = new_config.settings or {}
-- only send update when confiuration actually changed
if not vim.deep_equal(old_config, client.config.settings) then
if not vim.deep_equal(old_settings, client.config.settings) then
-- notify the lsp server of thr new config
local ok = pcall(client.notify, "workspace/didChangeConfiguration", {
settings = client.config.settings,