All the tutorials that I found to use nvim with rust-analyzer either suggest using Packer (which is unmaintained since August), vim plugin managers (I really want to avoid anything vimscript, it's hideous) or using mason-lspconfig which downloads its own rust-analyzer (a total dealbreaker, since a rust-analyzer decoupled from the rustc I actually use can cause plenty of issues, especially because I use nightly a lot).

What is the simplest config I need to have to setup Rust LSP in nvim using only lua, maintained plugin installer and the system rust-analyzer?

Note: I'm a complete nvim beginner, other than the location .config/nvim/nvim.lua and regular vim stuff, I know nothing. I believe (possibly it's improperly installed) I was able to successfully install treesitter using lazy.nvim.

1 Answer 1


Following the installation instructions for the Lazy plugin manager, place the following in ~/.config/nvim/init.lua:

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    "--branch=stable", -- latest stable release

-- Load plugins from lua/plugins.lua

Then the following Rust-related plugins should get you started:

Adding these to ~/.config/nvim/lua/plugins.lua:

return {
    { 'rust-lang/rust.vim' },
        version = '^3',
        ft = { 'rust' },

You can confirm this is using your system LSP via :checkhealth rustaceanvim after opening a Rust file:

Checking external dependencies
- OK rust-analyzer: found rust-analyzer 1.75.0 (82e1608 2023-12-21)

If instead you had accidentally installed Mason's rust-analyzer, this check would say something like

- OK rust-analyzer: found rust-analyzer 0.3.1799-standalone

In that event you could remove the Mason version with :MasonUninstall rust-analyzer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.