From 355e38162624fdd411bd19b1ca19e5e2733159ba Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Thu, 19 Dec 2024 20:36:54 +0000 Subject: [PATCH] feat: use `ui.text.directory` for path completion item if its a folder (#12295) --- helix-term/src/ui/completion.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs index c50832af9..ad317e39f 100644 --- a/helix-term/src/ui/completion.rs +++ b/helix-term/src/ui/completion.rs @@ -28,7 +28,7 @@ use helix_lsp::{lsp, util, OffsetEncoding}; impl menu::Item for CompletionItem { - type Data = (); + type Data = Style; fn sort_text(&self, data: &Self::Data) -> Cow { self.filter_text(data) } @@ -46,7 +46,7 @@ fn filter_text(&self, _data: &Self::Data) -> Cow { } } - fn format(&self, _data: &Self::Data) -> menu::Row { + fn format(&self, dir_style: &Self::Data) -> menu::Row { let deprecated = match self { CompletionItem::Lsp(LspCompletionItem { item, .. }) => { item.deprecated.unwrap_or_default() @@ -103,6 +103,8 @@ fn format(&self, _data: &Self::Data) -> menu::Row { label, if deprecated { Style::default().add_modifier(Modifier::CROSSED_OUT) + } else if kind == "folder" { + *dir_style } else { Style::default() }, @@ -135,8 +137,10 @@ pub fn new( // Sort completion items according to their preselect status (given by the LSP server) items.sort_by_key(|item| !item.preselect()); + let dir_style = editor.theme.get("ui.text.directory"); + // Then create the menu - let menu = Menu::new(items, (), move |editor: &mut Editor, item, event| { + let menu = Menu::new(items, dir_style, move |editor: &mut Editor, item, event| { let (view, doc) = current!(editor); macro_rules! language_server {