diff options
Diffstat (limited to 'helix-term/src/ui/mod.rs')
-rw-r--r-- | helix-term/src/ui/mod.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index a90debdb..2dca870b 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -298,6 +298,27 @@ pub mod completers { }) } + pub fn language(editor: &Editor, input: &str) -> Vec<Completion> { + let matcher = Matcher::default(); + + let mut matches: Vec<_> = editor + .syn_loader + .language_configs() + .filter_map(|config| { + matcher + .fuzzy_match(&config.language_id, input) + .map(|score| (&config.language_id, score)) + }) + .collect(); + + matches.sort_unstable_by_key(|(_language, score)| Reverse(*score)); + + matches + .into_iter() + .map(|(language, _score)| ((0..), language.clone().into())) + .collect() + } + pub fn directory(_editor: &Editor, input: &str) -> Vec<Completion> { filename_impl(input, |entry| { let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir()); |