Skip to content

Commit

Permalink
fix(lsp/windows): unable to find rust-analyzer executable binary
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Jan 23, 2025
1 parent 36ca5ef commit 8a2e4b5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lua/rustaceanvim/config/internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ local RustaceanConfig
local rustaceanvim = vim.g.rustaceanvim or {}
local rustaceanvim_opts = type(rustaceanvim) == 'function' and rustaceanvim() or rustaceanvim

---Wrapper around |vim.fn.exepath()| that returns the binary if no path is found.
---@param binary string
---@return string the full path to the executable or `binary` if no path is found.
---@see vim.fn.exepath()
local function exepath_or_binary(binary)
local exe_path = vim.fn.exepath(binary)
return #exe_path > 0 and exe_path or binary
end

---@class rustaceanvim.internal.RAInitializedStatus : rustaceanvim.RAInitializedStatus
---@field health rustaceanvim.lsp_server_health_status
---@field quiescent boolean inactive?
Expand Down Expand Up @@ -283,7 +292,7 @@ local RustaceanDefaultConfig = {
end,
---@type string[] | fun():(string[]|fun(dispatchers: vim.lsp.rpc.Dispatchers): vim.lsp.rpc.PublicClient)
cmd = function()
return { 'rust-analyzer', '--log-file', RustaceanConfig.server.logfile }
return { exepath_or_binary('rust-analyzer'), '--log-file', RustaceanConfig.server.logfile }
end,

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

0 comments on commit 8a2e4b5

Please sign in to comment.