From 8a788c764f579361debd5ec7894fa164f5a84630 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 2 Apr 2020 14:30:28 +0200 Subject: Allow fully overriding check and fmt commands --- crates/rust-analyzer/src/config.rs | 21 +++++++++++++++++++-- editors/code/package.json | 14 ++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index f3d8773cc..04f5bb473 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -133,13 +133,30 @@ impl Config { set(value, "/cargo/allFeatures", &mut self.cargo.all_features); set(value, "/cargo/features", &mut self.cargo.features); set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); - if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { + if let Some(mut args) = get::>(value, "/rustfmt/overrideCommand") { + if !args.is_empty() { + let command = args.remove(0); + self.rustfmt = RustfmtConfig::CustomCommand { + command, + args, + } + } + } else if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { set(value, "/rustfmt/extraArgs", extra_args); } if let Some(false) = get(value, "/checkOnSave/enable") { self.check = None } else { - if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check + if let Some(mut args) = get::>(value, "/checkOnSave/overrideCommand") { + if !args.is_empty() { + let command = args.remove(0); + self.check = Some(FlycheckConfig::CustomCommand { + command, + args, + }) + } + + } else if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check { set(value, "/checkOnSave/extraArgs", extra_args); set(value, "/checkOnSave/command", command); diff --git a/editors/code/package.json b/editors/code/package.json index 1f95cd130..e1c34c6ad 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -248,6 +248,13 @@ "default": [], "description": "Additional arguments to rustfmt" }, + "rust-analyzer.rustfmt.overrideCommand": { + "type": "array", + "items": { + "type": "string" + }, + "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for formatting." + }, "rust-analyzer.checkOnSave.enable": { "type": "boolean", "default": true, @@ -266,6 +273,13 @@ "default": "check", "markdownDescription": "Cargo command to use for `cargo check`" }, + "rust-analyzer.checkOnSave.overrideCommand": { + "type": "array", + "items": { + "type": "string" + }, + "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for checking. The command must include `--message=format=json`." + }, "rust-analyzer.checkOnSave.allTargets": { "type": "boolean", "default": true, -- cgit v1.2.3 From 407ab946ab5957ac92609b558c7ec15f0dfbb69a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 2 Apr 2020 14:39:37 +0200 Subject: better wording --- editors/code/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editors/code/package.json b/editors/code/package.json index e1c34c6ad..9c8cca615 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -278,7 +278,7 @@ "items": { "type": "string" }, - "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for checking. The command must include `--message=format=json`." + "markdownDescription": "Advanced option, fully override the command rust-analyzer uses for checking. The command should include `--message=format=json` or similar option." }, "rust-analyzer.checkOnSave.allTargets": { "type": "boolean", -- cgit v1.2.3