Skip to content
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

Add support for showing all LSPs in --health #7315

Merged
merged 10 commits into from
Oct 16, 2023
53 changes: 37 additions & 16 deletions helix-term/src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,40 @@ pub fn languages_all() -> std::io::Result<()> {
None => column("None", Color::Yellow),
};

let check_binaries = |cmds: Vec<String>| {
match cmds.len() {
0 => column("None", Color::Yellow),
1 => check_binary(cmds.get(0).cloned()),
n_configured => {
let n_available = cmds.iter().filter_map(|cmd| which::which(cmd).ok()).count();
match n_available {
0 => column(&format!("✘ 0/{}", n_configured), Color::Red),
n_available if n_available == n_configured => {
column(&format!("✓ {}/{}", n_available, n_configured), Color::Green)
}
n_available => column(
&format!("- {}/{}", n_available, n_configured),
Color::Yellow,
),
}
}
TheRealLorenz marked this conversation as resolved.
Show resolved Hide resolved
};
};

for lang in &syn_loader_conf.language {
column(&lang.language_id, Color::Reset);

// TODO multiple language servers (check binary for each supported language server, not just the first)

let lsp = lang.language_servers.first().and_then(|ls| {
syn_loader_conf
.language_server
.get(&ls.name)
.map(|config| config.command.clone())
});
check_binary(lsp);
let cmds = lang
.language_servers
.iter()
.filter_map(|ls| {
syn_loader_conf
.language_server
.get(&ls.name)
.map(|config| config.command.clone())
})
.collect();
check_binaries(cmds);

let dap = lang.debugger.as_ref().map(|dap| dap.command.to_string());
check_binary(dap);
Expand Down Expand Up @@ -268,16 +290,15 @@ pub fn language(lang_str: String) -> std::io::Result<()> {
}
};

// TODO multiple language servers
probe_protocol(
"language server",
lang.language_servers.first().and_then(|ls| {
for ls in &lang.language_servers {
probe_protocol(
"language server",
syn_loader_conf
.language_server
.get(&ls.name)
.map(|config| config.command.clone())
}),
)?;
.map(|config| config.command.clone()),
)?;
}

probe_protocol(
"debug adapter",
Expand Down