@@ -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
@@ -188,7 +163,7 @@ Starting rust-analyzer client in detached/standalone mode (with reduced function
188163 root_dir = os .normalize_path_on_windows (root_dir )
189164 lsp_start_config .root_dir = root_dir
190165
191- lsp_start_config .settings = get_start_settings (bufname , root_dir , client_config )
166+ lsp_start_config .settings = get_start_settings (root_dir , client_config )
192167 configure_file_watcher (lsp_start_config )
193168
194169 -- Check if a client is already running and add the workspace folder if necessary.
@@ -233,7 +208,7 @@ Starting rust-analyzer client in detached/standalone mode (with reduced function
233208 end
234209
235210 -- special case: rust-analyzer has a `rust-analyzer.server.path` config option
236- -- that allows you to override the path via .vscode/settings.json
211+ -- that allows you to override the path.
237212 local server_path = vim .tbl_get (lsp_start_config .settings , ' rust-analyzer' , ' server' , ' path' )
238213 if type (server_path ) == ' string' then
239214 if type (rust_analyzer_cmd ) == ' table' then
@@ -349,7 +324,7 @@ M.reload_settings = function(bufnr)
349324 local clients = rust_analyzer .get_active_rustaceanvim_clients (bufnr )
350325 --- @cast clients vim.lsp.Client[]
351326 for _ , client in ipairs (clients ) do
352- local settings = get_start_settings (vim . api . nvim_buf_get_name ( bufnr ), client .config .root_dir , config .server )
327+ local settings = get_start_settings (client .config .root_dir , config .server )
353328 --- @diagnostic disable-next-line : inject-field
354329 client .settings = settings
355330 client :notify (' workspace/didChangeConfiguration' , {
@@ -390,7 +365,7 @@ function M.set_config(ra_settings)
390365 local clients = rust_analyzer .get_active_rustaceanvim_clients (bufnr )
391366 --- @cast clients vim.lsp.Client[]
392367 for _ , client in ipairs (clients ) do
393- local settings = get_start_settings (vim . api . nvim_buf_get_name ( bufnr ), client .config .root_dir , config .server )
368+ local settings = get_start_settings (client .config .root_dir , config .server )
394369 --- @diagnostic disable-next-line : inject-field
395370 settings [' rust-analyzer' ] = vim .tbl_deep_extend (' force' , settings [' rust-analyzer' ], ra_settings )
396371 client .settings = settings
0 commit comments