Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lsp): normalize case sensitive root_dir on Windows #152

Merged
merged 5 commits into from
Jan 14, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lua/rustaceanvim/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ local function is_in_workspace(client, root_dir)
return false
end

--- Fast fix for root_dir fix on windows
---@param path string
---@return string normalize_path
local function normalize_path(path)
if require('rustaceanvim.shell').is_windows() then
local has_windows_drive_letter = path:match '^%a:'
if has_windows_drive_letter then
return path:sub(1,1):lower()..path:sub(2)
end
end
return path
end
mrcjkb marked this conversation as resolved.
Show resolved Hide resolved

--- Start or attach the LSP client
---@param bufnr? number The buffer number (optional), defaults to the current buffer
---@return integer|nil client_id The LSP client ID
Expand All @@ -105,6 +118,7 @@ M.start = function(bufnr)
---@type RustaceanLspClientConfig
local lsp_start_opts = vim.tbl_deep_extend('force', {}, client_config)
local root_dir = get_root_dir(vim.api.nvim_buf_get_name(bufnr))
root_dir = normalize_path(root_dir)
mrcjkb marked this conversation as resolved.
Show resolved Hide resolved
lsp_start_opts.root_dir = root_dir

local settings = client_config.settings
Expand Down
Loading