Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #17949 - Wilfred:include_build_file_in_watchers, r=lnicola
fix: rust-analyzer should watch build files from rust-project.json rust-analyzer always watches Cargo.toml for changes, but other build systems using rust-project.json have their own build files. Ensure we also watch those for changes, so we know when to reconfigure rust-analyzer when dependencies change.
bors 2024-08-24
parent ab34fdd · parent fa83d3c · commit 74a6427
-rw-r--r--crates/rust-analyzer/src/reload.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index 5d0c6b6599..8a28de10e8 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -564,6 +564,23 @@ impl GlobalState {
.collect()
};
+ // Also explicitly watch any build files configured in JSON project files.
+ for ws in self.workspaces.iter() {
+ if let ProjectWorkspaceKind::Json(project_json) = &ws.kind {
+ for (_, krate) in project_json.crates() {
+ let Some(build) = &krate.build else {
+ continue;
+ };
+ watchers.push(lsp_types::FileSystemWatcher {
+ glob_pattern: lsp_types::GlobPattern::String(
+ build.build_file.to_string(),
+ ),
+ kind: None,
+ });
+ }
+ }
+ }
+
watchers.extend(
iter::once(Config::user_config_path())
.chain(self.workspaces.iter().map(|ws| ws.manifest().map(ManifestPath::as_ref)))