Generalize Flycheckconfig
This commit is contained in:
parent
aad0e63d74
commit
f01846b8ee
2 changed files with 21 additions and 15 deletions
|
@ -23,10 +23,9 @@ use crate::conv::{map_rust_diagnostic_to_lsp, MappedRustDiagnostic};
|
||||||
pub use crate::conv::url_from_path_with_drive_lowercasing;
|
pub use crate::conv::url_from_path_with_drive_lowercasing;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct FlycheckConfig {
|
pub enum FlycheckConfig {
|
||||||
pub command: String,
|
CargoCommand { command: String, all_targets: bool, extra_args: Vec<String> },
|
||||||
pub all_targets: bool,
|
CustomCommand { command: String, args: Vec<String> },
|
||||||
pub extra_args: Vec<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flycheck wraps the shared state and communication machinery used for
|
/// Flycheck wraps the shared state and communication machinery used for
|
||||||
|
@ -215,18 +214,25 @@ impl FlycheckThread {
|
||||||
self.message_recv = never();
|
self.message_recv = never();
|
||||||
self.check_process = None;
|
self.check_process = None;
|
||||||
|
|
||||||
let cmd = {
|
let mut cmd = match &self.config {
|
||||||
let mut cmd = Command::new(cargo_binary());
|
FlycheckConfig::CargoCommand { command, all_targets, extra_args } => {
|
||||||
cmd.arg(&self.config.command);
|
let mut cmd = Command::new(cargo_binary());
|
||||||
cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]);
|
cmd.arg(command);
|
||||||
cmd.arg(self.workspace_root.join("Cargo.toml"));
|
cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]);
|
||||||
if self.config.all_targets {
|
cmd.arg(self.workspace_root.join("Cargo.toml"));
|
||||||
cmd.arg("--all-targets");
|
if *all_targets {
|
||||||
|
cmd.arg("--all-targets");
|
||||||
|
}
|
||||||
|
cmd.args(extra_args);
|
||||||
|
cmd
|
||||||
|
}
|
||||||
|
FlycheckConfig::CustomCommand { command, args } => {
|
||||||
|
let mut cmd = Command::new(command);
|
||||||
|
cmd.args(args);
|
||||||
|
cmd
|
||||||
}
|
}
|
||||||
cmd.args(self.config.extra_args.iter());
|
|
||||||
cmd.current_dir(&self.workspace_root);
|
|
||||||
cmd
|
|
||||||
};
|
};
|
||||||
|
cmd.current_dir(&self.workspace_root);
|
||||||
|
|
||||||
let (message_send, message_recv) = unbounded();
|
let (message_send, message_recv) = unbounded();
|
||||||
self.message_recv = message_recv;
|
self.message_recv = message_recv;
|
||||||
|
|
|
@ -102,7 +102,7 @@ fn get_config(
|
||||||
max_length: config.inlay_hints_max_length,
|
max_length: config.inlay_hints_max_length,
|
||||||
},
|
},
|
||||||
check: if config.cargo_watch_enable {
|
check: if config.cargo_watch_enable {
|
||||||
Some(FlycheckConfig {
|
Some(FlycheckConfig::CargoCommand {
|
||||||
command: config.cargo_watch_command.clone(),
|
command: config.cargo_watch_command.clone(),
|
||||||
all_targets: config.cargo_watch_all_targets,
|
all_targets: config.cargo_watch_all_targets,
|
||||||
extra_args: config.cargo_watch_args.clone(),
|
extra_args: config.cargo_watch_args.clone(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue