Rust Analyzer Setup in VS Code Neovim and Zed Editors
Set up rust-analyzer in VS Code, Neovim, Helix or Zed, and tune the settings that matter: check on save with Clippy, proc macro support, workspace loading and memory.

rust-analyzer is the part of an editor that turns Rust files into completions, errors and jump-to-definition. The defaults are good, and the problems come from three places: it fights your terminal for the build directory, it checks with plain cargo check when you wanted Clippy, and it runs out of patience on a huge workspace. This post fixes each. It extends the toolchain basics in rustup explained.
rust-analyzer current stable, Rust 1.90.
Install
- VS Code: install the "rust-analyzer" extension. It downloads the server.
- Neovim:
rustup component add rust-analyzerand configurelspconfig.rust_analyzer. - Helix, Zed: both detect
rust-analyzeron yourPATH; Zed bundles it.
Add rust-src so the standard library is navigable: rustup component add rust-src, or list it in rust-toolchain.toml.
Settings worth setting
In VS Code settings.json (the same keys apply to other editors under rust-analyzer.):
{
"rust-analyzer.check.command": "clippy",
"rust-analyzer.cargo.targetDir": true,
"rust-analyzer.cargo.features": "all",
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.files.excludeDirs": ["target", "node_modules", "frontend"]
}| Setting | Why |
|---|---|
check.command = "clippy" | lints appear in the editor as you save |
cargo.targetDir = true | uses target/rust-analyzer, so editor and terminal builds do not wait on one lock |
cargo.features = "all" | analyzes every feature combination; set a list for crates with conflicting features |
procMacro.enable | needed for serde, thiserror and attribute macros |
The targetDir option doubles disk use for the project. The trade is worth it, because an editor check that blocks cargo test for ten seconds is annoying every time.
Check what it sees
Run the command "rust-analyzer: Status" in VS Code. It lists the workspace roots, the cfg flags and whether proc macros loaded. If it says "no workspace", the folder opened does not contain a Cargo.toml at its root; open the folder containing it, or add the path in rust-analyzer.linkedProjects.
Slow or wrong results
The usual causes of slow or wrong results are:
- Wrong cfg: code under
#[cfg(feature = "x")]is greyed out because the feature is off. Enable it incargo.features. - Stale build script output: restart the server after changing
build.rs. - Two toolchains: the server and the terminal use different compilers.
rustup showin the project folder reveals it. - Memory growth: exclude directories that contain no Rust.
Inlay hints
Type and parameter hints are on by default and can feel noisy. Turn off the ones you dislike under inlayHints.*. They are rendered from analysis and do not change the file.
Where it differs from the compiler
rust-analyzer has its own type checker and can disagree with rustc on edge cases, particularly with complex trait solving. When the editor shows an error that cargo build does not, trust the compiler. The manual is at rust-analyzer.github.io.


