Skip to content

Commit

Permalink
fix(lsp/windows): path normalisation preventing lsp to work after gd …
Browse files Browse the repository at this point in the history
…to std lib (#285)
  • Loading branch information
tangtang95 authored Mar 10, 2024
1 parent c616605 commit a59b4e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lua/rustaceanvim/cargo.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local compat = require('rustaceanvim.compat')
local rust_analyzer = require('rustaceanvim.rust_analyzer')
local os = require('rustaceanvim.os')
local joinpath = compat.joinpath

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

for _, item in ipairs { toolchains, registry } do
item = os.normalize_path_on_windows(item)
if file_name:sub(1, #item) == item then
local clients = rust_analyzer.get_active_rustaceanvim_clients()
return clients and #clients > 0 and clients[#clients].config.root_dir or nil
Expand Down
2 changes: 1 addition & 1 deletion lua/rustaceanvim/os.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end
---@return string normalized_path
function os.normalize_path_on_windows(path)
if shell.is_windows() and starts_with_windows_drive_letter(path) then
return path:sub(1, 1):lower() .. path:sub(2)
return path:sub(1, 1):lower() .. path:sub(2):gsub('/+', '\\')
end
return path
end
Expand Down

0 comments on commit a59b4e0

Please sign in to comment.