@@ -37,41 +37,16 @@ local function is_in_workspace(client, root_dir)
3737 return false
3838end
3939
40- --- Searches upward for a .vscode/settings.json that contains rust-analyzer
41- --- settings and returns them.
42- --- @param bufname string
43- --- @return table server_settings or an empty table if no settings were found
44- local function find_vscode_settings (bufname )
45- local settings = {}
46- local found_dirs = vim .fs .find ({ ' .vscode' }, { upward = true , path = vim .fs .dirname (bufname ), type = ' directory' })
47- if vim .tbl_isempty (found_dirs ) then
48- return settings
49- end
50- local vscode_dir = found_dirs [1 ]
51- local results = vim .fn .glob (vim .fs .joinpath (vscode_dir , ' settings.json' ), true , true )
52- if vim .tbl_isempty (results ) then
53- return settings
54- end
55- local content = os .read_file (results [1 ])
56- return content and require (' rustaceanvim.config.json' ).silent_decode (content ) or {}
57- end
58-
5940--- Generate the settings from config and vscode settings if found.
6041--- settings and returns them.
61- --- @param bufname string
6242--- @param root_dir string | nil
6343--- @param client_config table
6444--- @return table server_settings or an empty table if no settings were found
65- local function get_start_settings (bufname , root_dir , client_config )
45+ local function get_start_settings (root_dir , client_config )
6646 local settings = client_config .settings
6747 local evaluated_settings = type (settings ) == ' function' and settings (root_dir , client_config .default_settings )
6848 or settings
6949
70- if config .server .load_vscode_settings then
71- local json_settings = find_vscode_settings (bufname )
72- require (' rustaceanvim.config.json' ).override_with_rust_analyzer_json_keys (evaluated_settings , json_settings )
73- end
74-
7550 return evaluated_settings
7651end
7752
@@ -199,7 +174,7 @@ Starting rust-analyzer client in detached/standalone mode (with reduced function
199174 root_dir = os .normalize_path_on_windows (root_dir )
200175 lsp_start_config .root_dir = root_dir
201176
202- lsp_start_config .settings = get_start_settings (bufname , root_dir , client_config )
177+ lsp_start_config .settings = get_start_settings (root_dir , client_config )
203178 configure_file_watcher (lsp_start_config )
204179
205180 -- Check if a client is already running and add the workspace folder if necessary.
@@ -244,7 +219,7 @@ Starting rust-analyzer client in detached/standalone mode (with reduced function
244219 end
245220
246221 -- special case: rust-analyzer has a `rust-analyzer.server.path` config option
247- -- that allows you to override the path via .vscode/settings.json
222+ -- that allows you to override the path.
248223 local server_path = vim .tbl_get (lsp_start_config .settings , ' rust-analyzer' , ' server' , ' path' )
249224 if type (server_path ) == ' string' then
250225 if type (rust_analyzer_cmd ) == ' table' then
@@ -361,7 +336,7 @@ M.reload_settings = function(bufnr)
361336 local clients = rust_analyzer .get_active_rustaceanvim_clients (bufnr )
362337 --- @cast clients vim.lsp.Client[]
363338 for _ , client in ipairs (clients ) do
364- local settings = get_start_settings (vim . api . nvim_buf_get_name ( bufnr ), client .config .root_dir , config .server )
339+ local settings = get_start_settings (client .config .root_dir , config .server )
365340 --- @diagnostic disable-next-line : inject-field
366341 client .settings = settings
367342 client :notify (' workspace/didChangeConfiguration' , {
@@ -403,7 +378,7 @@ function M.set_config(bufnr, ra_settings)
403378 local clients = rust_analyzer .get_active_rustaceanvim_clients (bufnr )
404379 --- @cast clients vim.lsp.Client[]
405380 for _ , client in ipairs (clients ) do
406- local settings = get_start_settings (vim . api . nvim_buf_get_name ( bufnr ), client .config .root_dir , config .server )
381+ local settings = get_start_settings (client .config .root_dir , config .server )
407382 --- @diagnostic disable-next-line : inject-field
408383 settings [' rust-analyzer' ] = vim .tbl_deep_extend (' force' , settings [' rust-analyzer' ], ra_settings )
409384 client .settings = settings
0 commit comments