Hi all,
I’m trying to get a rust environment set up using rust-tools
. LspInfo
shows that rust-analyzer is attached to my buffer but I’m running into two issues:
-
When I exit neovim,
rust-analyzer
stays open (and uses quite a bit of CPU – usage climbs steadily until it hits 100% and then stays there). And when I open neovim, it spins up a new instance ofrust-analyzer
instead of connecting to the old one. So the result is that if I open / close neovim a few times I end up with a bunch of copies of the LSP eating all my resources. -
Some features don’t work but others do. Snippets, code actions, and linting seem to work, but I don’t get completion suggestions (e.g.
my_string.s
I would expect completion for string methods that start withs
, but instead I only get snippet suggestions) and inline typehints fromrust-tools
don’t appear.
I’m pretty confident this is a neovim issue or an lsp-config issue. I’ve tried installing different versions of the rust toolchain, different projects, different installation methods for rust-analyzer, and using plain lsp-config
without rust-tools
. In all of those cases the problem still persists.
My configuration for LSP:
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local lspconfig = require("lspconfig")
local servers = {
...
"rust_analyzer",
...
}
for _, lsp in ipairs(servers) do
if lsp == "rust_analyzer" then
require("rust-tools").setup({
server = { capabilities = capabilities, standalone = true },
})
else
lspconfig[lsp].setup({
capabilities = capabilities,
})
end
end
nvim --version
output:
NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by _nixbld11
Features: +acl +iconv +tui
rust-analyzer --version
output:
rust-analyzer 2022-10-31
Platform:
macOS 13.0.1 (Ventura) on aarch64 (Apple Silicon)
Thanks in advance for your help!