mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Use experimental capability to enable color codes
This commit is contained in:
parent
738ce83d85
commit
65cf7abbe2
5 changed files with 24 additions and 11 deletions
|
@ -47,6 +47,7 @@ pub enum FlycheckConfig {
|
|||
features: Vec<String>,
|
||||
extra_args: Vec<String>,
|
||||
extra_env: FxHashMap<String, String>,
|
||||
ansi_color_output: bool,
|
||||
},
|
||||
CustomCommand {
|
||||
command: String,
|
||||
|
@ -293,16 +294,21 @@ impl FlycheckActor {
|
|||
extra_args,
|
||||
features,
|
||||
extra_env,
|
||||
ansi_color_output,
|
||||
} => {
|
||||
let mut cmd = Command::new(toolchain::cargo());
|
||||
cmd.arg(command);
|
||||
cmd.current_dir(&self.root);
|
||||
cmd.args([
|
||||
"--workspace",
|
||||
"--message-format=json-diagnostic-rendered-ansi",
|
||||
"--manifest-path",
|
||||
])
|
||||
.arg(self.root.join("Cargo.toml").as_os_str());
|
||||
cmd.arg("--workspace");
|
||||
|
||||
cmd.arg(if *ansi_color_output {
|
||||
"--message-format=json-diagnostic-rendered-ansi"
|
||||
} else {
|
||||
"--message-format=json"
|
||||
});
|
||||
|
||||
cmd.arg("--manifest-path");
|
||||
cmd.arg(self.root.join("Cargo.toml").as_os_str());
|
||||
|
||||
for target in target_triples {
|
||||
cmd.args(["--target", target.as_str()]);
|
||||
|
|
|
@ -161,8 +161,8 @@ config_data! {
|
|||
/// Override the command rust-analyzer uses instead of `cargo check` for
|
||||
/// diagnostics on save. The command is required to output json and
|
||||
/// should therefore include `--message-format=json` or a similar option
|
||||
/// (for colored diagnostics, use
|
||||
/// `--message-format=json-diagnostic-rendered-ansi`).
|
||||
/// (if your client supports the `colorDiagnosticOutput` experimental
|
||||
/// capability, you can use `--message-format=json-diagnostic-rendered-ansi`).
|
||||
///
|
||||
/// If you're changing this because you're using some tool wrapping
|
||||
/// Cargo, you might also want to change
|
||||
|
@ -1008,6 +1008,11 @@ impl Config {
|
|||
self.experimental("serverStatusNotification")
|
||||
}
|
||||
|
||||
/// Whether the client supports colored output for full diagnostics from `checkOnSave`.
|
||||
pub fn color_diagnostic_output(&self) -> bool {
|
||||
self.experimental("colorDiagnosticOutput")
|
||||
}
|
||||
|
||||
pub fn publish_diagnostics(&self) -> bool {
|
||||
self.data.diagnostics_enable
|
||||
}
|
||||
|
@ -1206,6 +1211,7 @@ impl Config {
|
|||
},
|
||||
extra_args: self.data.check_extraArgs.clone(),
|
||||
extra_env: self.check_on_save_extra_env(),
|
||||
ansi_color_output: self.color_diagnostic_output(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue