Skip to content

Commit

Permalink
feat: use ui.text.directory for path completion item if its a folder (
Browse files Browse the repository at this point in the history
  • Loading branch information
nik-rev authored Dec 19, 2024
1 parent cbc06d1 commit 355e381
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::ui::{menu, Markdown, Menu, Popup, PromptEvent};
use helix_lsp::{lsp, util, OffsetEncoding};

impl menu::Item for CompletionItem {
type Data = ();
type Data = Style;
fn sort_text(&self, data: &Self::Data) -> Cow<str> {
self.filter_text(data)
}
Expand All @@ -46,7 +46,7 @@ impl menu::Item for CompletionItem {
}
}

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()
Expand Down Expand Up @@ -103,6 +103,8 @@ impl menu::Item for CompletionItem {
label,
if deprecated {
Style::default().add_modifier(Modifier::CROSSED_OUT)
} else if kind == "folder" {
*dir_style
} else {
Style::default()
},
Expand Down Expand Up @@ -135,8 +137,10 @@ impl Completion {
// 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 {
Expand Down

0 comments on commit 355e381

Please sign in to comment.