From b373e62f1a3785b35572113797cbfa72861712b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Apr 2022 19:02:45 -0300 Subject: [PATCH] Reload project on .cargo/config[.toml] changes Fixes #11024 --- crates/rust-analyzer/src/config.rs | 2 +- crates/rust-analyzer/src/reload.rs | 5 +++++ docs/user/generated_config.adoc | 2 +- editors/code/package.json | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 833ee31eed..05ea67b411 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -67,7 +67,7 @@ config_data! { callInfo_full: bool = "true", /// Automatically refresh project info via `cargo metadata` on - /// `Cargo.toml` changes. + /// `Cargo.toml` or `.cargo/config.toml` changes. cargo_autoreload: bool = "true", /// Activate all available features (`--all-features`). cargo_allFeatures: bool = "false", diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index b68f9d5f59..650ce6d30a 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -617,6 +617,11 @@ pub(crate) fn should_refresh_for_change(path: &AbsPath, change_kind: ChangeKind) return false; } if path.extension().unwrap_or_default() != "rs" { + if (file_name == "config.toml" || file_name == "config") + && path.parent().map(|parent| parent.as_ref().ends_with(".cargo")) == Some(true) + { + return true; + } return false; } if IMPLICIT_TARGET_FILES.iter().any(|it| path.as_ref().ends_with(it)) { diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc index ace74f8e08..a9dcdfd696 100644 --- a/docs/user/generated_config.adoc +++ b/docs/user/generated_config.adoc @@ -42,7 +42,7 @@ Show function name and docs in parameter hints. + -- Automatically refresh project info via `cargo metadata` on -`Cargo.toml` changes. +`Cargo.toml` or `.cargo/config.toml` changes. -- [[rust-analyzer.cargo.allFeatures]]rust-analyzer.cargo.allFeatures (default: `false`):: + diff --git a/editors/code/package.json b/editors/code/package.json index cd0ad92d9a..9f0f53196a 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -439,7 +439,7 @@ "type": "boolean" }, "rust-analyzer.cargo.autoreload": { - "markdownDescription": "Automatically refresh project info via `cargo metadata` on\n`Cargo.toml` changes.", + "markdownDescription": "Automatically refresh project info via `cargo metadata` on\n`Cargo.toml` or `.cargo/config.toml` changes.", "default": true, "type": "boolean" },