Closed TisnKu closed 2 years ago
Seems that using lsp-setup, the cmd
for rust lsp is not correct.
Can you provide a reproducible minimal configuration?
Sure. https://github.com/TisnKu/rust-lsp-setup-repro Plugins are in init.lua and lsp configs are in https://github.com/TisnKu/rust-lsp-setup-repro/blob/304929bb9a657e3af4688c5a13d406792429fb6d/after/plugin/lsp.lua.
If I do a fresh reinstall using :MasonInstall rust-analyzer, it can be loaded immediately. If I quit nvim and reopen the project, it will not load.
It seems that mason doesn't install rust-analyzer
automatically, or the installation fails.
You need to check if rust-analyzer
is installed successfully. The following two commands may help you:
Sure. https://github.com/TisnKu/rust-lsp-setup-repro Plugins are in init.lua and lsp configs are in https://github.com/TisnKu/rust-lsp-setup-repro/blob/304929bb9a657e3af4688c5a13d406792429fb6d/after/plugin/lsp.lua.
I am not sure if we need to specify bundle_path
It is installed, just not attached to the buffer. Bundle_path is my random trial to fix the bug, the bug is the same with or without it.
The installation path of rust-analyzer.
Can you delete the rust-analyzer
(:LspUninstall rust-analyzer) and restart neovim? Then check if mason will automatically install rust-analyzer
.
Yes, mason will install rust-analyzer automatically.
BTW, on my mac, the same configuration works.
I did some tests for other lsps as well, taplo
and rust-analyzer
have the same issue, tsserver
and jsonls
does not.
Sorry, I can't see that this is a problem with lsp-setup, lsp-setup just wraps mason, as you said, it is working on mac.
If I replace lsp-setup
with require('lspconfig').rust_analyzer.setup {}
, it works. Maybe it's a problem of mason-lspconfig
After some testing, I found that with only mason-lspconfig
, it still works. So I modified the code of lsp-setup just like the example of mason-lspconfig
, and it works:
It's kind of weird why order matters on windows. Any particular reason to put setup_handler
before setup
?
I opened an issue for mason-lspconfig
and owner confirmed that setup
should be placed before setup_handler
. Do you mind fixing it or accept PR?
https://github.com/williamboman/mason-lspconfig.nvim/issues/78
I opened an issue for mason-lspconfig and owner confirmed that setup should be placed before setup_handler. Do you mind fixing it or accept PR?
Thanks, PRs are doubly welcome!
Hi there, thanks for the plugin. I found the bug that rust lsp cannot load. If I do a fresh reinstall using
:MasonInstall rust-analyzer
, it can be loaded immediately. If I quit nvim and reopen the project, it will not load.Another workaround is to do a manual setup of rust-analyzer using
require('lsp-config').rust_analyzer.setup()
and remove rust from lsp-setup.nvim.Open the main.rs in the project, rust lsp cannot load.
Reinstall rust-analyzer using mason, lsp can be loaded.