mirror of
https://github.com/helix-editor/helix.git
synced 2025-01-18 21:17:08 +04:00
feat: use ui.text.directory
for path completion item if its a folder (#12295)
This commit is contained in:
parent
cbc06d1f15
commit
355e381626
@ -28,7 +28,7 @@
|
|||||||
use helix_lsp::{lsp, util, OffsetEncoding};
|
use helix_lsp::{lsp, util, OffsetEncoding};
|
||||||
|
|
||||||
impl menu::Item for CompletionItem {
|
impl menu::Item for CompletionItem {
|
||||||
type Data = ();
|
type Data = Style;
|
||||||
fn sort_text(&self, data: &Self::Data) -> Cow<str> {
|
fn sort_text(&self, data: &Self::Data) -> Cow<str> {
|
||||||
self.filter_text(data)
|
self.filter_text(data)
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ fn filter_text(&self, _data: &Self::Data) -> Cow<str> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn format(&self, _data: &Self::Data) -> menu::Row {
|
fn format(&self, dir_style: &Self::Data) -> menu::Row {
|
||||||
let deprecated = match self {
|
let deprecated = match self {
|
||||||
CompletionItem::Lsp(LspCompletionItem { item, .. }) => {
|
CompletionItem::Lsp(LspCompletionItem { item, .. }) => {
|
||||||
item.deprecated.unwrap_or_default()
|
item.deprecated.unwrap_or_default()
|
||||||
@ -103,6 +103,8 @@ fn format(&self, _data: &Self::Data) -> menu::Row {
|
|||||||
label,
|
label,
|
||||||
if deprecated {
|
if deprecated {
|
||||||
Style::default().add_modifier(Modifier::CROSSED_OUT)
|
Style::default().add_modifier(Modifier::CROSSED_OUT)
|
||||||
|
} else if kind == "folder" {
|
||||||
|
*dir_style
|
||||||
} else {
|
} else {
|
||||||
Style::default()
|
Style::default()
|
||||||
},
|
},
|
||||||
@ -135,8 +137,10 @@ pub fn new(
|
|||||||
// Sort completion items according to their preselect status (given by the LSP server)
|
// Sort completion items according to their preselect status (given by the LSP server)
|
||||||
items.sort_by_key(|item| !item.preselect());
|
items.sort_by_key(|item| !item.preselect());
|
||||||
|
|
||||||
|
let dir_style = editor.theme.get("ui.text.directory");
|
||||||
|
|
||||||
// Then create the menu
|
// 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);
|
let (view, doc) = current!(editor);
|
||||||
|
|
||||||
macro_rules! language_server {
|
macro_rules! language_server {
|
||||||
|
Loading…
Reference in New Issue
Block a user