Skip to content

Commit b21d68c

Browse files
committed
feat: add proc-macro rebuild on save option
Signed-off-by: ClSlaid <[email protected]>
1 parent e402c49 commit b21d68c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ config_data! {
105105
/// ```
106106
/// .
107107
cargo_buildScripts_overrideCommand: Option<Vec<String>> = "null",
108+
/// rerun proc-macros building/build-scripts running when proc-macro
109+
/// or build-script sources change and are saved.
110+
cargo_buildScripts_rebuildOnSave: bool = "false",
108111
/// Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to
109112
/// avoid checking unnecessary things.
110113
cargo_buildScripts_useRustcWrapper: bool = "true",
@@ -1368,6 +1371,10 @@ impl Config {
13681371
self.data.checkOnSave
13691372
}
13701373

1374+
pub fn script_rebuild_on_save(&self) -> bool {
1375+
self.data.cargo_buildScripts_rebuildOnSave
1376+
}
1377+
13711378
pub fn runnables(&self) -> RunnablesConfig {
13721379
RunnablesConfig {
13731380
override_cargo: self.data.runnables_command.clone(),

crates/rust-analyzer/src/global_state.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ impl GlobalState {
351351

352352
crates.iter().any(|&krate| crate_graph[krate].is_proc_macro)
353353
});
354+
if self.proc_macro_changed && self.config.script_rebuild_on_save() {
355+
self.fetch_build_data_queue
356+
.request_op(format!("proc-macro or build script source changed"), ())
357+
}
354358
}
355359

356360
true

0 commit comments

Comments
 (0)