rustrust-analyzerzed

How to make Rust Analyzer to check when you type in Zed?


I'm trying Zed editor to develop Rust project and it work perfectly except one annoying thing: I can't configure Rust Analyzer to run checks when I type, like it does in VS Code. In Zed Rust Analyzer re-checks only on save and I can't find anywhere how to configure it to do this on the fly when I type. Anybody knows how to do this?


Solution

  • Checking, as in cargo check, which runs the compiler to obtain diagnostics, can only run against saved files — there is no protocol by which rust-analyzer can give Cargo unsaved files. However, rust-analyzer also has a subset of diagnostics implemented internally which are able to update as you type. These diagnostics largely attempt to mimic rustc diagnostics, though they are marked as being from rust-analyzer (at least in VS Code; I don’t use Zed myself).

    rust-analyzer built-in diagnostics are controlled by the settings named rust-analyzer.diagnostics.*. Check to make sure you don’t have them disabled.