File tree 4 files changed +25
-0
lines changed
4 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,9 @@ config_data! {
105
105
/// ```
106
106
/// .
107
107
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" ,
108
111
/// Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to
109
112
/// avoid checking unnecessary things.
110
113
cargo_buildScripts_useRustcWrapper: bool = "true" ,
@@ -1369,6 +1372,10 @@ impl Config {
1369
1372
self . data . checkOnSave
1370
1373
}
1371
1374
1375
+ pub fn script_rebuild_on_save ( & self ) -> bool {
1376
+ self . data . cargo_buildScripts_rebuildOnSave
1377
+ }
1378
+
1372
1379
pub fn runnables ( & self ) -> RunnablesConfig {
1373
1380
RunnablesConfig {
1374
1381
override_cargo : self . data . runnables_command . clone ( ) ,
Original file line number Diff line number Diff line change @@ -130,6 +130,13 @@ pub(crate) fn handle_did_save_text_document(
130
130
state : & mut GlobalState ,
131
131
params : DidSaveTextDocumentParams ,
132
132
) -> anyhow:: Result < ( ) > {
133
+ if state. config . script_rebuild_on_save ( ) && state. proc_macro_changed {
134
+ // reset the flag
135
+ state. proc_macro_changed = false ;
136
+ // rebuild the proc macros
137
+ state. fetch_build_data_queue . request_op ( "ScriptRebuildOnSave" . to_owned ( ) , ( ) ) ;
138
+ }
139
+
133
140
if let Ok ( vfs_path) = from_proto:: vfs_path ( & params. text_document . uri ) {
134
141
// Re-fetch workspaces if a workspace related file has changed
135
142
if let Some ( abs_path) = vfs_path. as_path ( ) {
Original file line number Diff line number Diff line change @@ -71,6 +71,12 @@ cargo check --quiet --workspace --message-format=json --all-targets
71
71
```
72
72
.
73
73
--
74
+ [[rust-analyzer.cargo.buildScripts.rebuildOnSave]]rust-analyzer.cargo.buildScripts.rebuildOnSave (default: `false` )::
75
+ +
76
+ --
77
+ Rerun proc-macros building/build-scripts running when proc-macro
78
+ or build-script sources change and are saved.
79
+ --
74
80
[[rust-analyzer.cargo.buildScripts.useRustcWrapper]]rust-analyzer.cargo.buildScripts.useRustcWrapper (default: `true` )::
75
81
+
76
82
--
Original file line number Diff line number Diff line change 586
586
"type" : " string"
587
587
}
588
588
},
589
+ "rust-analyzer.cargo.buildScripts.rebuildOnSave" : {
590
+ "markdownDescription" : " Rerun proc-macros building/build-scripts running when proc-macro\n or build-script sources change and are saved." ,
591
+ "default" : false ,
592
+ "type" : " boolean"
593
+ },
589
594
"rust-analyzer.cargo.buildScripts.useRustcWrapper" : {
590
595
"markdownDescription" : " Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to\n avoid checking unnecessary things." ,
591
596
"default" : true ,
You can’t perform that action at this time.
0 commit comments