diff options
-rw-r--r-- | crates/ra_flycheck/src/lib.rs | 34 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 2 |
2 files changed, 21 insertions, 15 deletions
diff --git a/crates/ra_flycheck/src/lib.rs b/crates/ra_flycheck/src/lib.rs index ee09d8de3..f099bdfe8 100644 --- a/crates/ra_flycheck/src/lib.rs +++ b/crates/ra_flycheck/src/lib.rs | |||
@@ -23,10 +23,9 @@ use crate::conv::{map_rust_diagnostic_to_lsp, MappedRustDiagnostic}; | |||
23 | pub use crate::conv::url_from_path_with_drive_lowercasing; | 23 | pub use crate::conv::url_from_path_with_drive_lowercasing; |
24 | 24 | ||
25 | #[derive(Clone, Debug)] | 25 | #[derive(Clone, Debug)] |
26 | pub struct FlycheckConfig { | 26 | pub enum FlycheckConfig { |
27 | pub command: String, | 27 | CargoCommand { command: String, all_targets: bool, extra_args: Vec<String> }, |
28 | pub all_targets: bool, | 28 | CustomCommand { command: String, args: Vec<String> }, |
29 | pub extra_args: Vec<String>, | ||
30 | } | 29 | } |
31 | 30 | ||
32 | /// Flycheck wraps the shared state and communication machinery used for | 31 | /// Flycheck wraps the shared state and communication machinery used for |
@@ -215,18 +214,25 @@ impl FlycheckThread { | |||
215 | self.message_recv = never(); | 214 | self.message_recv = never(); |
216 | self.check_process = None; | 215 | self.check_process = None; |
217 | 216 | ||
218 | let cmd = { | 217 | let mut cmd = match &self.config { |
219 | let mut cmd = Command::new(cargo_binary()); | 218 | FlycheckConfig::CargoCommand { command, all_targets, extra_args } => { |
220 | cmd.arg(&self.config.command); | 219 | let mut cmd = Command::new(cargo_binary()); |
221 | cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]); | 220 | cmd.arg(command); |
222 | cmd.arg(self.workspace_root.join("Cargo.toml")); | 221 | cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]); |
223 | if self.config.all_targets { | 222 | cmd.arg(self.workspace_root.join("Cargo.toml")); |
224 | cmd.arg("--all-targets"); | 223 | if *all_targets { |
224 | cmd.arg("--all-targets"); | ||
225 | } | ||
226 | cmd.args(extra_args); | ||
227 | cmd | ||
228 | } | ||
229 | FlycheckConfig::CustomCommand { command, args } => { | ||
230 | let mut cmd = Command::new(command); | ||
231 | cmd.args(args); | ||
232 | cmd | ||
225 | } | 233 | } |
226 | cmd.args(self.config.extra_args.iter()); | ||
227 | cmd.current_dir(&self.workspace_root); | ||
228 | cmd | ||
229 | }; | 234 | }; |
235 | cmd.current_dir(&self.workspace_root); | ||
230 | 236 | ||
231 | let (message_send, message_recv) = unbounded(); | 237 | let (message_send, message_recv) = unbounded(); |
232 | self.message_recv = message_recv; | 238 | self.message_recv = message_recv; |
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 06122ed95..a89ea86ea 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -102,7 +102,7 @@ fn get_config( | |||
102 | max_length: config.inlay_hints_max_length, | 102 | max_length: config.inlay_hints_max_length, |
103 | }, | 103 | }, |
104 | check: if config.cargo_watch_enable { | 104 | check: if config.cargo_watch_enable { |
105 | Some(FlycheckConfig { | 105 | Some(FlycheckConfig::CargoCommand { |
106 | command: config.cargo_watch_command.clone(), | 106 | command: config.cargo_watch_command.clone(), |
107 | all_targets: config.cargo_watch_all_targets, | 107 | all_targets: config.cargo_watch_all_targets, |
108 | extra_args: config.cargo_watch_args.clone(), | 108 | extra_args: config.cargo_watch_args.clone(), |