@@ -185,24 +185,26 @@ pub fn languages_all() -> std::io::Result<()> {
185
185
. language
186
186
. sort_unstable_by_key ( |l| l. language_id . clone ( ) ) ;
187
187
188
- let check_binary = |cmd : Option < & str > | match cmd {
189
- Some ( cmd) => match helix_stdx:: env:: which ( cmd) {
190
- Ok ( _) => color ( fit ( & format ! ( "✓ {}" , cmd ) ) , Color :: Green ) ,
191
- Err ( _) => color ( fit ( & format ! ( "✘ {}" , cmd ) ) , Color :: Red ) ,
188
+ let check_binary_with_name = |cmd : Option < ( & str , & str ) > | match cmd {
189
+ Some ( ( name , cmd) ) => match helix_stdx:: env:: which ( cmd) {
190
+ Ok ( _) => color ( fit ( & format ! ( "✓ {}" , name ) ) , Color :: Green ) ,
191
+ Err ( _) => color ( fit ( & format ! ( "✘ {}" , name ) ) , Color :: Red ) ,
192
192
} ,
193
193
None => color ( fit ( "None" ) , Color :: Yellow ) ,
194
194
} ;
195
195
196
+ let check_binary = |cmd : Option < & str > | check_binary_with_name ( cmd. map ( |cmd| ( cmd, cmd) ) ) ;
197
+
196
198
for lang in & syn_loader_conf. language {
197
199
write ! ( stdout, "{}" , fit( & lang. language_id) ) ?;
198
200
199
201
let mut cmds = lang. language_servers . iter ( ) . filter_map ( |ls| {
200
202
syn_loader_conf
201
203
. language_server
202
204
. get ( & ls. name )
203
- . map ( |config| config. command . as_str ( ) )
205
+ . map ( |config| ( ls . name . as_str ( ) , config. command . as_str ( ) ) )
204
206
} ) ;
205
- write ! ( stdout, "{}" , check_binary ( cmds. next( ) ) ) ?;
207
+ write ! ( stdout, "{}" , check_binary_with_name ( cmds. next( ) ) ) ?;
206
208
207
209
let dap = lang. debugger . as_ref ( ) . map ( |dap| dap. command . as_str ( ) ) ;
208
210
write ! ( stdout, "{}" , check_binary( dap) ) ?;
@@ -224,7 +226,7 @@ pub fn languages_all() -> std::io::Result<()> {
224
226
225
227
for cmd in cmds {
226
228
write ! ( stdout, "{}" , fit( "" ) ) ?;
227
- writeln ! ( stdout, "{}" , check_binary ( Some ( cmd) ) ) ?;
229
+ writeln ! ( stdout, "{}" , check_binary_with_name ( Some ( cmd) ) ) ?;
228
230
}
229
231
}
230
232
@@ -283,10 +285,12 @@ pub fn language(lang_str: String) -> std::io::Result<()> {
283
285
284
286
probe_protocols (
285
287
"language server" ,
286
- lang. language_servers
287
- . iter ( )
288
- . filter_map ( |ls| syn_loader_conf. language_server . get ( & ls. name ) )
289
- . map ( |config| config. command . as_str ( ) ) ,
288
+ lang. language_servers . iter ( ) . filter_map ( |ls| {
289
+ syn_loader_conf
290
+ . language_server
291
+ . get ( & ls. name )
292
+ . map ( |config| ( ls. name . as_str ( ) , config. command . as_str ( ) ) )
293
+ } ) ,
290
294
) ?;
291
295
292
296
probe_protocol (
@@ -323,7 +327,7 @@ fn probe_parser(grammar_name: &str) -> std::io::Result<()> {
323
327
}
324
328
325
329
/// Display diagnostics about multiple LSPs and DAPs.
326
- fn probe_protocols < ' a , I : Iterator < Item = & ' a str > + ' a > (
330
+ fn probe_protocols < ' a , I : Iterator < Item = ( & ' a str , & ' a str ) > + ' a > (
327
331
protocol_name : & str ,
328
332
server_cmds : I ,
329
333
) -> std:: io:: Result < ( ) > {
@@ -338,12 +342,12 @@ fn probe_protocols<'a, I: Iterator<Item = &'a str> + 'a>(
338
342
}
339
343
writeln ! ( stdout) ?;
340
344
341
- for cmd in server_cmds {
342
- let ( path , icon) = match helix_stdx:: env:: which ( cmd) {
345
+ for ( name , cmd) in server_cmds {
346
+ let ( diag , icon) = match helix_stdx:: env:: which ( cmd) {
343
347
Ok ( path) => ( path. display ( ) . to_string ( ) . green ( ) , "✓" . green ( ) ) ,
344
348
Err ( _) => ( format ! ( "'{}' not found in $PATH" , cmd) . red ( ) , "✘" . red ( ) ) ,
345
349
} ;
346
- writeln ! ( stdout, " {} {}: {}" , icon, cmd , path ) ?;
350
+ writeln ! ( stdout, " {} {}: {}" , icon, name , diag ) ?;
347
351
}
348
352
349
353
Ok ( ( ) )
@@ -354,19 +358,18 @@ fn probe_protocol(protocol_name: &str, server_cmd: Option<String>) -> std::io::R
354
358
let stdout = std:: io:: stdout ( ) ;
355
359
let mut stdout = stdout. lock ( ) ;
356
360
357
- let cmd_name = match server_cmd {
358
- Some ( ref cmd) => cmd. as_str ( ) . green ( ) ,
359
- None => "None" . yellow ( ) ,
361
+ write ! ( stdout, "Configured {}:" , protocol_name) ?;
362
+ let Some ( cmd) = server_cmd else {
363
+ writeln ! ( stdout, "{}" , " None" . yellow( ) ) ?;
364
+ return Ok ( ( ) ) ;
360
365
} ;
361
- writeln ! ( stdout, "Configured {}: {}" , protocol_name , cmd_name ) ?;
366
+ writeln ! ( stdout) ?;
362
367
363
- if let Some ( cmd) = server_cmd {
364
- let path = match helix_stdx:: env:: which ( & cmd) {
365
- Ok ( path) => path. display ( ) . to_string ( ) . green ( ) ,
366
- Err ( _) => format ! ( "'{}' not found in $PATH" , cmd) . red ( ) ,
367
- } ;
368
- writeln ! ( stdout, "Binary for {}: {}" , protocol_name, path) ?;
369
- }
368
+ let ( diag, icon) = match helix_stdx:: env:: which ( & cmd) {
369
+ Ok ( path) => ( path. display ( ) . to_string ( ) . green ( ) , "✓" . green ( ) ) ,
370
+ Err ( _) => ( format ! ( "'{}' not found in $PATH" , cmd) . red ( ) , "✘" . red ( ) ) ,
371
+ } ;
372
+ writeln ! ( stdout, " {} {}" , icon, diag) ?;
370
373
371
374
Ok ( ( ) )
372
375
}
0 commit comments