Show parser availability in --health [LANG] (#12228)

This commit is contained in:
Eduardo Rittner Coelho 2024-12-18 14:21:58 -03:00 committed by GitHub
parent 13e5a2ee5a
commit 9e4da4b950
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -307,6 +307,8 @@ pub fn language(lang_str: String) -> std::io::Result<()> {
.map(|formatter| formatter.command.to_string()),
)?;
probe_parser(lang.grammar.as_ref().unwrap_or(&lang.language_id))?;
for ts_feat in TsFeature::all() {
probe_treesitter_feature(&lang_str, *ts_feat)?
}
@ -314,6 +316,18 @@ pub fn language(lang_str: String) -> std::io::Result<()> {
Ok(())
}
fn probe_parser(grammar_name: &str) -> std::io::Result<()> {
let stdout = std::io::stdout();
let mut stdout = stdout.lock();
write!(stdout, "Tree-sitter parser: ")?;
match helix_loader::grammar::get_language(grammar_name) {
Ok(_) => writeln!(stdout, "{}", "".green()),
Err(_) => writeln!(stdout, "{}", "None".yellow()),
}
}
/// Display diagnostics about multiple LSPs and DAPs.
fn probe_protocols<'a, I: Iterator<Item = &'a str> + 'a>(
protocol_name: &str,