Skip to content

Commit

Permalink
feat(lsp): allow overriding server command via `rust-analzyer.server.…
Browse files Browse the repository at this point in the history
…path` setting (#567)
  • Loading branch information
mrcjkb authored Nov 10, 2024
1 parent 2444433 commit 7a8665b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lua/rustaceanvim/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,19 @@ M.start = function(bufnr)
end

local rust_analyzer_cmd = types.evaluate(client_config.cmd)
if #rust_analyzer_cmd == 0 or vim.fn.executable(rust_analyzer_cmd[1]) ~= 1 then
vim.notify('rust-analyzer binary not found.', vim.log.levels.ERROR)
-- special case: rust-analyzer has a `rust-analyzer.server.path` config option
-- that allows you to override the path via .vscode/settings.json
local server_path = vim.tbl_get(lsp_start_config.settings, 'rust-analyzer', 'server', 'path')
if type(server_path) == 'string' then
rust_analyzer_cmd[1] = server_path
--
end
if #rust_analyzer_cmd == 0 then
vim.notify('rust-analyzer command is not set!', vim.log.levels.ERROR)
return
end
if vim.fn.executable(rust_analyzer_cmd[1]) ~= 1 then
vim.notify(('%s is not executable'):format(rust_analyzer_cmd[1]), vim.log.levels.ERROR)
return
end
---@cast rust_analyzer_cmd string[]
Expand Down

0 comments on commit 7a8665b

Please sign in to comment.