I'm trying to get rust-analyzer working in Neovim, but with no luck so far.
I've downloaded the rust-analyzer binary (rust-analyzer-x86_64-pc-windows-msvc.gz
) from the rust-analyzer releases page and put it in my PATH (specifically in %USERPROFILE%\.rustup\toolchains\rust-analyzer-x86_64-pc-windows-msvc
).
I have the language server enabled in my init.lua but when I open a source file in a rust project and enter :LspInfo
I get the following:
Config: rust_analyzer
filetypes: rust
root directory: C:\Users\[my user name]\source\repos\rust\loops
cmd: rust-analyzer
cmd is executable: Unable to find executable. Please check your path and ensure the server is installed
autostart: true
custom handlers:
My init.lua for lsp config looks like this:
local servers = { 'gopls', 'lemminx', 'rust_analyzer' }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
}
end
gopls
is working all fine, so I think that config is correct. But rust-analyzer just doesn't seem to work.
I've also tried installing rust-analyzer in VSCode in case neovim can use that one, but that didn't appear to work either.
I'm using v0.5.0 of neovim.
I read on some webpage that I've now lost that the rust-analyzer MSVC needs to be registered but I can't find any info on how to register an MSVC.
For comparison, this is what :LspInfo
shows when I have a Go source file open and the gopls
LSP is attached:
Client: gopls (id: 1, pid: 59572, bufnr: [1])
filetypes: go, gomod
autostart: true
root directory: C:\Users\[my user name]\source\repos\go\k6-extensions\xk6-wsrte
cmd: gopls
rust-analyzer
, or is the commandrust-analyzer-x86_64-pc-windows-msvc
? It's not clear from your description of the paths involvedrust_analyzer
but the error message saysrust-analyzer
. I don't know where thecmd
value is coming from. Runningrust-analyzer
orrust_analyzer
from command line just gets the "is not recognized as a name of a cmdlet etc" response. Same for tryingrust-analyzer-x86_64-pc-windows-msvc
.nvim-lspconfig
folders there's arust_analyzer.lua
file that defines thecmd
- which is 'rust-analyzer'. This has been most educational!