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

[Windows] rustaceanvim spawns many instances of RustAnalyzer #151

Closed
TrungNguyen153 opened this issue Jan 12, 2024 · 4 comments · Fixed by #152
Closed

[Windows] rustaceanvim spawns many instances of RustAnalyzer #151

TrungNguyen153 opened this issue Jan 12, 2024 · 4 comments · Fixed by #152
Labels
bug Something isn't working

Comments

@TrungNguyen153
Copy link
Contributor

Neovim version (nvim -v)

0.9.5-> nightly 0.10.xx

Operating system/version

Windows

Output of :checkhealth rustaceanvim

==============================================================================
rustaceanvim: require("rustaceanvim.health").check()

Checking for Lua dependencies ~
- OK [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap) installed.

Checking external dependencies ~
- OK rust-analyzer: found rust-analyzer 0.3.1791-standalone (9db515503 2024-01-01)
- OK Cargo: found 
- OK rustc: found 
- OK debug adapter: found codelldb 

Checking config ~
- OK No errors found in config.

Checking for conflicting plugins ~
- OK No conflicting plugins detected.

How to reproduce the issue

.

Expected behaviour

Only spawn 1 instance RustAnalyzer on root_dir project

Actual behaviour

By some how plugin spawn 2 RustAnalyzer instance on same root because vim.lsp.start(lsp_options).
It spawn 2 kind of this path:
root directory: D:\rust-workspace\same-project-a
root directory: d:\rust-workspace\same-project-a
yes. difference is D vs d => vim.lsp.start spawn 2 instance on same-project-a

The minimal config used to reproduce this issue.

.
@TrungNguyen153 TrungNguyen153 added the bug Something isn't working label Jan 12, 2024
@TrungNguyen153
Copy link
Contributor Author

seem vim.api.nvim_buf_get_name return difference Case sensive for file in root dir

@TrungNguyen153
Copy link
Contributor Author

and root problem is here neovim/nvim-lspconfig#1168 and neovim/neovim#16331

@TrungNguyen153
Copy link
Contributor Author

fast fix is:
local function normalize_path(path)
local has_windows_drive_letter = path:match '^%a:'
if has_windows_drive_letter then
return path:sub(1,1):lower()..path:sub(2)
end
return path
end
lsp_start_opts.root_dir = normalize_path(root_dir)

https://github.com/mrcjkb/rustaceanvim/blob/master/lua/rustaceanvim/lsp.lua#L108C3-L108C37

@mrcjkb mrcjkb changed the title Lsp spawn many instance RustAnalyzer [Windows] rustaceanvim spawns many instances of RustAnalyzer Jan 12, 2024
@mrcjkb
Copy link
Owner

mrcjkb commented Jan 12, 2024

Thanks for the detailed report 🙏

@mrcjkb mrcjkb linked a pull request Jan 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants