Skip to content

Commit 9694dfd

Browse files
authored
fix(lsp/windows): unable to find rust-analyzer executable binary (#665)
1 parent 36ca5ef commit 9694dfd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lua/rustaceanvim/config/internal.lua

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ local RustaceanConfig
1010
local rustaceanvim = vim.g.rustaceanvim or {}
1111
local rustaceanvim_opts = type(rustaceanvim) == 'function' and rustaceanvim() or rustaceanvim
1212

13+
---Wrapper around |vim.fn.exepath()| that returns the binary if no path is found.
14+
---@param binary string
15+
---@return string the full path to the executable or `binary` if no path is found.
16+
---@see vim.fn.exepath()
17+
local function exepath_or_binary(binary)
18+
local exe_path = vim.fn.exepath(binary)
19+
return #exe_path > 0 and exe_path or binary
20+
end
21+
1322
---@class rustaceanvim.internal.RAInitializedStatus : rustaceanvim.RAInitializedStatus
1423
---@field health rustaceanvim.lsp_server_health_status
1524
---@field quiescent boolean inactive?
@@ -283,7 +292,7 @@ local RustaceanDefaultConfig = {
283292
end,
284293
---@type string[] | fun():(string[]|fun(dispatchers: vim.lsp.rpc.Dispatchers): vim.lsp.rpc.PublicClient)
285294
cmd = function()
286-
return { 'rust-analyzer', '--log-file', RustaceanConfig.server.logfile }
295+
return { exepath_or_binary('rust-analyzer'), '--log-file', RustaceanConfig.server.logfile }
287296
end,
288297

289298
---@type string | fun(filename: string, default: fun(filename: string):string|nil):string|nil

0 commit comments

Comments
 (0)