diff options
author | Josh Mcguigan <[email protected]> | 2020-04-07 05:41:31 +0100 |
---|---|---|
committer | Josh Mcguigan <[email protected]> | 2020-04-07 05:41:31 +0100 |
commit | 8f7fceeb9ceab6383deae8895c88b3ba53f8dabe (patch) | |
tree | 141457681118671f58c055321b6a8f80f713224a /crates | |
parent | c859a6480af7baece2eec38c19f71cb714db9e3b (diff) |
fix cargo check config with custom command
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index b6a015790..4734df16a 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -131,37 +131,47 @@ impl Config { | |||
131 | set(value, "/cargo/allFeatures", &mut self.cargo.all_features); | 131 | set(value, "/cargo/allFeatures", &mut self.cargo.all_features); |
132 | set(value, "/cargo/features", &mut self.cargo.features); | 132 | set(value, "/cargo/features", &mut self.cargo.features); |
133 | set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); | 133 | set(value, "/cargo/loadOutDirsFromCheck", &mut self.cargo.load_out_dirs_from_check); |
134 | if let Some(mut args) = get::<Vec<String>>(value, "/rustfmt/overrideCommand") { | 134 | match get::<Vec<String>>(value, "/rustfmt/overrideCommand") { |
135 | if !args.is_empty() { | 135 | Some(mut args) if !args.is_empty() => { |
136 | let command = args.remove(0); | 136 | let command = args.remove(0); |
137 | self.rustfmt = RustfmtConfig::CustomCommand { | 137 | self.rustfmt = RustfmtConfig::CustomCommand { |
138 | command, | 138 | command, |
139 | args, | 139 | args, |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } else if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { | 142 | _ => { |
143 | set(value, "/rustfmt/extraArgs", extra_args); | 143 | if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt { |
144 | } | 144 | set(value, "/rustfmt/extraArgs", extra_args); |
145 | } | ||
146 | } | ||
147 | }; | ||
145 | 148 | ||
146 | if let Some(false) = get(value, "/checkOnSave/enable") { | 149 | if let Some(false) = get(value, "/checkOnSave/enable") { |
150 | // check is disabled | ||
147 | self.check = None; | 151 | self.check = None; |
148 | } else { | 152 | } else { |
149 | if let Some(mut args) = get::<Vec<String>>(value, "/checkOnSave/overrideCommand") { | 153 | // check is enabled |
150 | if !args.is_empty() { | 154 | match get::<Vec<String>>(value, "/checkOnSave/overrideCommand") { |
155 | // first see if the user has completely overridden the command | ||
156 | Some(mut args) if !args.is_empty() => { | ||
151 | let command = args.remove(0); | 157 | let command = args.remove(0); |
152 | self.check = Some(FlycheckConfig::CustomCommand { | 158 | self.check = Some(FlycheckConfig::CustomCommand { |
153 | command, | 159 | command, |
154 | args, | 160 | args, |
155 | }); | 161 | }); |
156 | } | 162 | } |
157 | 163 | // otherwise configure command customizations | |
158 | } else if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check | 164 | _ => { |
159 | { | 165 | if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) |
160 | set(value, "/checkOnSave/extraArgs", extra_args); | 166 | = &mut self.check |
161 | set(value, "/checkOnSave/command", command); | 167 | { |
162 | set(value, "/checkOnSave/allTargets", all_targets); | 168 | set(value, "/checkOnSave/extraArgs", extra_args); |
163 | } | 169 | set(value, "/checkOnSave/command", command); |
164 | }; | 170 | set(value, "/checkOnSave/allTargets", all_targets); |
171 | } | ||
172 | } | ||
173 | }; | ||
174 | } | ||
165 | 175 | ||
166 | set(value, "/inlayHints/typeHints", &mut self.inlay_hints.type_hints); | 176 | set(value, "/inlayHints/typeHints", &mut self.inlay_hints.type_hints); |
167 | set(value, "/inlayHints/parameterHints", &mut self.inlay_hints.parameter_hints); | 177 | set(value, "/inlayHints/parameterHints", &mut self.inlay_hints.parameter_hints); |