Skip to content

Commit a59b4e0

Browse files
authored
fix(lsp/windows): path normalisation preventing lsp to work after gd to std lib (#285)
1 parent c616605 commit a59b4e0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lua/rustaceanvim/cargo.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local compat = require('rustaceanvim.compat')
22
local rust_analyzer = require('rustaceanvim.rust_analyzer')
3+
local os = require('rustaceanvim.os')
34
local joinpath = compat.joinpath
45

56
local cargo = {}
@@ -17,6 +18,7 @@ local function get_mb_active_client_root(file_name)
1718
local toolchains = joinpath(rustup_home, 'toolchains')
1819

1920
for _, item in ipairs { toolchains, registry } do
21+
item = os.normalize_path_on_windows(item)
2022
if file_name:sub(1, #item) == item then
2123
local clients = rust_analyzer.get_active_rustaceanvim_clients()
2224
return clients and #clients > 0 and clients[#clients].config.root_dir or nil

lua/rustaceanvim/os.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ end
4545
---@return string normalized_path
4646
function os.normalize_path_on_windows(path)
4747
if shell.is_windows() and starts_with_windows_drive_letter(path) then
48-
return path:sub(1, 1):lower() .. path:sub(2)
48+
return path:sub(1, 1):lower() .. path:sub(2):gsub('/+', '\\')
4949
end
5050
return path
5151
end

0 commit comments

Comments
 (0)