File tree Expand file tree Collapse file tree 4 files changed +25
-0
lines changed Expand file tree Collapse file tree 4 files changed +25
-0
lines changed Original file line number Diff line number Diff 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" ,
@@ -1369,6 +1372,10 @@ impl Config {
13691372 self . data . checkOnSave
13701373 }
13711374
1375+ pub fn script_rebuild_on_save ( & self ) -> bool {
1376+ self . data . cargo_buildScripts_rebuildOnSave
1377+ }
1378+
13721379 pub fn runnables ( & self ) -> RunnablesConfig {
13731380 RunnablesConfig {
13741381 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(
130130 state : & mut GlobalState ,
131131 params : DidSaveTextDocumentParams ,
132132) -> 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+
133140 if let Ok ( vfs_path) = from_proto:: vfs_path ( & params. text_document . uri ) {
134141 // Re-fetch workspaces if a workspace related file has changed
135142 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
7171```
7272.
7373--
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+ --
7480[[rust-analyzer.cargo.buildScripts.useRustcWrapper]]rust-analyzer.cargo.buildScripts.useRustcWrapper (default: `true` )::
7581+
7682--
Original file line number Diff line number Diff line change 586586 "type" : " string"
587587 }
588588 },
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+ },
589594 "rust-analyzer.cargo.buildScripts.useRustcWrapper" : {
590595 "markdownDescription" : " Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to\n avoid checking unnecessary things." ,
591596 "default" : true ,
You can’t perform that action at this time.
0 commit comments