Skip to content

Commit 7a8665b

Browse files
authored
feat(lsp): allow overriding server command via rust-analzyer.server.path setting (#567)
1 parent 2444433 commit 7a8665b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lua/rustaceanvim/lsp/init.lua

+13-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,19 @@ M.start = function(bufnr)
199199
end
200200

201201
local rust_analyzer_cmd = types.evaluate(client_config.cmd)
202-
if #rust_analyzer_cmd == 0 or vim.fn.executable(rust_analyzer_cmd[1]) ~= 1 then
203-
vim.notify('rust-analyzer binary not found.', vim.log.levels.ERROR)
202+
-- special case: rust-analyzer has a `rust-analyzer.server.path` config option
203+
-- that allows you to override the path via .vscode/settings.json
204+
local server_path = vim.tbl_get(lsp_start_config.settings, 'rust-analyzer', 'server', 'path')
205+
if type(server_path) == 'string' then
206+
rust_analyzer_cmd[1] = server_path
207+
--
208+
end
209+
if #rust_analyzer_cmd == 0 then
210+
vim.notify('rust-analyzer command is not set!', vim.log.levels.ERROR)
211+
return
212+
end
213+
if vim.fn.executable(rust_analyzer_cmd[1]) ~= 1 then
214+
vim.notify(('%s is not executable'):format(rust_analyzer_cmd[1]), vim.log.levels.ERROR)
204215
return
205216
end
206217
---@cast rust_analyzer_cmd string[]

0 commit comments

Comments
 (0)