mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Auto merge of #16011 - ClSlaid:feat/settings/proc-macro/rebuild-on-save, r=Veykril
feat: add proc-macro rebuild on save option Related: #15033 I need some advice on how to test it.
This commit is contained in:
commit
f1de7d7273
4 changed files with 25 additions and 0 deletions
|
@ -105,6 +105,9 @@ config_data! {
|
|||
/// ```
|
||||
/// .
|
||||
cargo_buildScripts_overrideCommand: Option<Vec<String>> = "null",
|
||||
/// Rerun proc-macros building/build-scripts running when proc-macro
|
||||
/// or build-script sources change and are saved.
|
||||
cargo_buildScripts_rebuildOnSave: bool = "false",
|
||||
/// Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to
|
||||
/// avoid checking unnecessary things.
|
||||
cargo_buildScripts_useRustcWrapper: bool = "true",
|
||||
|
@ -1369,6 +1372,10 @@ impl Config {
|
|||
self.data.checkOnSave
|
||||
}
|
||||
|
||||
pub fn script_rebuild_on_save(&self) -> bool {
|
||||
self.data.cargo_buildScripts_rebuildOnSave
|
||||
}
|
||||
|
||||
pub fn runnables(&self) -> RunnablesConfig {
|
||||
RunnablesConfig {
|
||||
override_cargo: self.data.runnables_command.clone(),
|
||||
|
|
|
@ -130,6 +130,13 @@ pub(crate) fn handle_did_save_text_document(
|
|||
state: &mut GlobalState,
|
||||
params: DidSaveTextDocumentParams,
|
||||
) -> anyhow::Result<()> {
|
||||
if state.config.script_rebuild_on_save() && state.proc_macro_changed {
|
||||
// reset the flag
|
||||
state.proc_macro_changed = false;
|
||||
// rebuild the proc macros
|
||||
state.fetch_build_data_queue.request_op("ScriptRebuildOnSave".to_owned(), ());
|
||||
}
|
||||
|
||||
if let Ok(vfs_path) = from_proto::vfs_path(¶ms.text_document.uri) {
|
||||
// Re-fetch workspaces if a workspace related file has changed
|
||||
if let Some(abs_path) = vfs_path.as_path() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue