diff options
author | Aleksey Kladov <[email protected]> | 2020-04-02 13:30:28 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-04-02 13:35:51 +0100 |
commit | 8a788c764f579361debd5ec7894fa164f5a84630 (patch) | |
tree | 1d624f581d490339fbfae9a342af5af2f50dd722 /crates | |
parent | 7a4ebd2c8dfee8ca15dab7ba053a6521840aa5e3 (diff) |
Allow fully overriding check and fmt commands
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 21 |
1 files changed, 19 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 { | |||
133 | set(value, "/cargo/allFeatures", &mut self.cargo.all_features); | 133 | set(value, "/cargo/allFeatures", &mut self.cargo.all_features); |
134 | set(value, "/cargo/features", &mut self.cargo.features); | 134 | set(value, "/cargo/features", &mut self.cargo.features); |
135 | set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); | 135 | 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 { | ||
137 | set(value, "/rustfmt/extraArgs", extra_args); | 145 | set(value, "/rustfmt/extraArgs", extra_args); |
138 | } | 146 | } |
139 | if let Some(false) = get(value, "/checkOnSave/enable") { | 147 | if let Some(false) = get(value, "/checkOnSave/enable") { |
140 | self.check = None | 148 | self.check = None |
141 | } else { | 149 | } 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 | ||
143 | { | 160 | { |
144 | set(value, "/checkOnSave/extraArgs", extra_args); | 161 | set(value, "/checkOnSave/extraArgs", extra_args); |
145 | set(value, "/checkOnSave/command", command); | 162 | set(value, "/checkOnSave/command", command); |