Make checkOnSave workspace

This commit is contained in:
Ali Bektas 2024-08-22 19:07:43 +02:00
parent 648545276a
commit 15a1505551
3 changed files with 9 additions and 8 deletions

View file

@ -76,8 +76,6 @@ config_data! {
/// How many worker threads to handle priming caches. The default `0` means to pick automatically.
cachePriming_numThreads: NumThreads = NumThreads::Physical,
/// Run the check command for diagnostics on save.
checkOnSave | checkOnSave_enable: bool = true,
/// Check all targets and tests (`--all-targets`). Defaults to
/// `#rust-analyzer.cargo.allTargets#`.
@ -350,7 +348,7 @@ config_data! {
workspace: struct WorkspaceDefaultConfigData <- WorkspaceConfigInput -> {
/// Pass `--all-targets` to cargo invocation.
/// Pass `--all-targets` to cargo invocation.
cargo_allTargets: bool = true,
/// Automatically refresh project info via `cargo metadata` on
/// `Cargo.toml` or `.cargo/config.toml` changes.
@ -431,6 +429,9 @@ config_data! {
/// set to a path relative to the workspace to use that path.
cargo_targetDir | rust_analyzerTargetDir: Option<TargetDirectory> = None,
/// Run the check command for diagnostics on save.
checkOnSave | checkOnSave_enable: bool = true,
/// Additional arguments to `rustfmt`.
rustfmt_extraArgs: Vec<String> = vec![],
/// Advanced option, fully override the command rust-analyzer uses for
@ -1960,8 +1961,8 @@ impl Config {
})
}
pub fn check_on_save(&self) -> bool {
*self.checkOnSave()
pub fn check_on_save(&self, source_root: Option<SourceRootId>) -> bool {
*self.checkOnSave(source_root)
}
pub fn script_rebuild_on_save(&self, source_root: Option<SourceRootId>) -> bool {

View file

@ -189,10 +189,10 @@ pub(crate) fn handle_did_save_text_document(
}
}
if !state.config.check_on_save() || run_flycheck(state, vfs_path) {
if !state.config.check_on_save(Some(sr)) || run_flycheck(state, vfs_path) {
return Ok(());
}
} else if state.config.check_on_save() {
} else if state.config.check_on_save(None) {
// No specific flycheck was triggered, so let's trigger all of them.
for flycheck in state.flycheck.iter() {
flycheck.restart_workspace(None);

View file

@ -404,7 +404,7 @@ impl GlobalState {
if self.is_quiescent() {
let became_quiescent = !was_quiescent;
if became_quiescent {
if self.config.check_on_save() {
if self.config.check_on_save(None) {
// Project has loaded properly, kick off initial flycheck
self.flycheck.iter().for_each(|flycheck| flycheck.restart_workspace(None));
}