Use rust-analyzer's flycheck as source of cargo diagnostics (#29779)

Follow-up of https://github.com/zed-industries/zed/pull/29706

Instead of doing `cargo check` manually, use rust-analyzer's flycheck:
at the cost of more sophisticated check command configuration, we keep
much less code in Zed, and get a proper progress report.

User-facing UI does not change except `diagnostics_fetch_command` and
`env` settings removed from the diagnostics settings.

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2025-05-02 10:07:51 +03:00 committed by GitHub
parent 672a1dd553
commit ba59305510
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 520 additions and 1071 deletions

View file

@ -155,37 +155,12 @@ pub struct InlineDiagnosticsSettings {
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
pub struct CargoDiagnosticsSettings {
/// When enabled, Zed runs `cargo check --message-format=json`-based commands and
/// collect cargo diagnostics instead of rust-analyzer.
/// When enabled, Zed disables rust-analyzer's check on save and starts to query
/// Cargo diagnostics separately.
///
/// Default: false
#[serde(default)]
pub fetch_cargo_diagnostics: bool,
/// A command override for fetching the cargo diagnostics.
/// First argument is the command, followed by the arguments.
///
/// Default: ["cargo", "check", "--quiet", "--workspace", "--message-format=json", "--all-targets", "--keep-going"]
#[serde(default = "default_diagnostics_fetch_command")]
pub diagnostics_fetch_command: Vec<String>,
/// Extra environment variables to pass to the diagnostics fetch command.
///
/// Default: {}
#[serde(default)]
pub env: HashMap<String, String>,
}
fn default_diagnostics_fetch_command() -> Vec<String> {
vec![
"cargo".to_string(),
"check".to_string(),
"--quiet".to_string(),
"--workspace".to_string(),
"--message-format=json".to_string(),
"--all-targets".to_string(),
"--keep-going".to_string(),
]
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema)]