feat: use ui.text.directory
for path completion item if its a folder (#12295)
This commit is contained in:
parent
cbc06d1f15
commit
355e381626
1 changed files with 7 additions and 3 deletions
|
@ -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)
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
},
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue