-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
health: add formatter binary #5692
Conversation
This adds a new output to --health that displays the formatter binary.
fn probe_commands(formatter_cmd: Option<String>) -> std::io::Result<()> { | ||
let stdout = std::io::stdout(); | ||
let mut stdout = stdout.lock(); | ||
|
||
if let Some(cmd) = formatter_cmd { | ||
let path = match which::which(&cmd) { | ||
Ok(path) => path.display().to_string().green(), | ||
Err(_) => format!("'{}' not found in $PATH", cmd).red(), | ||
}; | ||
writeln!(stdout, "Binary for formatter: {}", path)?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might make it more generic for checking any binary exists? Might not get the lock on stdout if the binary's path is None
.
fn probe_commands(formatter_cmd: Option<String>) -> std::io::Result<()> { | |
let stdout = std::io::stdout(); | |
let mut stdout = stdout.lock(); | |
if let Some(cmd) = formatter_cmd { | |
let path = match which::which(&cmd) { | |
Ok(path) => path.display().to_string().green(), | |
Err(_) => format!("'{}' not found in $PATH", cmd).red(), | |
}; | |
writeln!(stdout, "Binary for formatter: {}", path)?; | |
} | |
Ok(()) | |
} | |
fn probe_binary(binary_name: &str, binary_path: Option<String>) -> std::io::Result<()> { | |
if let Some(bin) = binary_path { | |
let stdout = std::io::stdout(); | |
let mut stdout = stdout.lock(); | |
let path = match which::which(&bin) { | |
Ok(path) => path.display().to_string().green(), | |
Err(_) => format!("'{}' not found in $PATH", bin).red(), | |
}; | |
writeln!(stdout, "Binary for {}: {}", binary_name, path)?; | |
} | |
Ok(()) | |
} | |
I feel more comfortable with a solution like this. In this case probe_commands has the same goal that probe_protocol. So just change some naming and the calls from the LSP, DAP and add the formatter one. Tests OK and is working properly. |
Fixed in #7986 |
I noticed that some languages have external formatters that are not a part of their LSP configuration.
To surface that information, this PR adds a new output to --health that displays the formatter binary.
In the future, this could be expanded to look for other fields that contain commands from the language config.
Here's some example output.