Skip to content

Commit

Permalink
Auto merge of #17949 - Wilfred:include_build_file_in_watchers, r=lnicola
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Aug 24, 2024
2 parents ab34fdd + fa83d3c commit 74a6427
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crates/rust-analyzer/src/reload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 74a6427

Please sign in to comment.