Skip to content

Commit 47a4850

Browse files
bors[bot]matklad
andauthored
Merge #3825
3825: Allow fully overriding check and fmt commands r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 3c9e9d3 + 407ab94 commit 47a4850

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,30 @@ impl Config {
133133
set(value, "/cargo/allFeatures", &mut self.cargo.all_features);
134134
set(value, "/cargo/features", &mut self.cargo.features);
135135
set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check);
136-
if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt {
136+
if let Some(mut args) = get::<Vec<String>>(value, "/rustfmt/overrideCommand") {
137+
if !args.is_empty() {
138+
let command = args.remove(0);
139+
self.rustfmt = RustfmtConfig::CustomCommand {
140+
command,
141+
args,
142+
}
143+
}
144+
} else if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt {
137145
set(value, "/rustfmt/extraArgs", extra_args);
138146
}
139147
if let Some(false) = get(value, "/checkOnSave/enable") {
140148
self.check = None
141149
} else {
142-
if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check
150+
if let Some(mut args) = get::<Vec<String>>(value, "/checkOnSave/overrideCommand") {
151+
if !args.is_empty() {
152+
let command = args.remove(0);
153+
self.check = Some(FlycheckConfig::CustomCommand {
154+
command,
155+
args,
156+
})
157+
}
158+
159+
} else if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check
143160
{
144161
set(value, "/checkOnSave/extraArgs", extra_args);
145162
set(value, "/checkOnSave/command", command);

editors/code/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@
248248
"default": [],
249249
"description": "Additional arguments to rustfmt"
250250
},
251+
"rust-analyzer.rustfmt.overrideCommand": {
252+
"type": "array",
253+
"items": {
254+
"type": "string"
255+
},
256+
"markdownDescription": "Advanced option, fully override the command rust-analyzer uses for formatting."
257+
},
251258
"rust-analyzer.checkOnSave.enable": {
252259
"type": "boolean",
253260
"default": true,
@@ -266,6 +273,13 @@
266273
"default": "check",
267274
"markdownDescription": "Cargo command to use for `cargo check`"
268275
},
276+
"rust-analyzer.checkOnSave.overrideCommand": {
277+
"type": "array",
278+
"items": {
279+
"type": "string"
280+
},
281+
"markdownDescription": "Advanced option, fully override the command rust-analyzer uses for checking. The command should include `--message=format=json` or similar option."
282+
},
269283
"rust-analyzer.checkOnSave.allTargets": {
270284
"type": "boolean",
271285
"default": true,

0 commit comments

Comments
 (0)