Skip to content

Commit 4885fed

Browse files
committed
Merge rust-analyzer settings instead of overwriting
1 parent 1aac1be commit 4885fed

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/building/suggested.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,18 @@ vim.lsp.config("rust_analyzer", {
202202
default_root_dir(bufnr, on_dir)
203203
end,
204204
before_init = function(init_params, config)
205-
-- When inside rust-lang/rust, we need to use the special rust_analyzer settings.
205+
-- When inside rust-lang/rust, we need to use the special rust-analyzer settings.
206206
local settings = vim.fs.joinpath(config.root_dir, "src/etc/rust_analyzer_zed.json")
207207
if vim.uv.fs_stat(settings) then
208208
local file = io.open(settings)
209209
-- nvim 0.12+ supports comments otherwise you'll need content:gsub("//[^\n]*", "").
210210
local json = vim.json.decode(file:read("*a"), { skip_comments = true })
211211
file:close()
212-
config.settings["rust-analyzer"] = json.lsp["rust-analyzer"].initialization_options
212+
config.settings["rust-analyzer"] = vim.tbl_deep_extend(
213+
"force", -- Overwrite with the special settings when there is a conflict.
214+
config.settings["rust-analyzer"] or {},
215+
json.lsp["rust-analyzer"].initialization_options
216+
)
213217
end
214218
default_before_init(init_params, config)
215219
end,

0 commit comments

Comments
 (0)