diff --git a/assets/icons/completion_icons/class.svg b/assets/icons/completion_icons/class.svg
new file mode 100644
index 0000000000000..822df21435d4c
--- /dev/null
+++ b/assets/icons/completion_icons/class.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/color.svg b/assets/icons/completion_icons/color.svg
new file mode 100644
index 0000000000000..d349be9b1d858
--- /dev/null
+++ b/assets/icons/completion_icons/color.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/constant.svg b/assets/icons/completion_icons/constant.svg
new file mode 100644
index 0000000000000..7fff581644b40
--- /dev/null
+++ b/assets/icons/completion_icons/constant.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/constructor.svg b/assets/icons/completion_icons/constructor.svg
new file mode 100644
index 0000000000000..f4e8df704c08b
--- /dev/null
+++ b/assets/icons/completion_icons/constructor.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/enum.svg b/assets/icons/completion_icons/enum.svg
new file mode 100644
index 0000000000000..ff6e87257d5b3
--- /dev/null
+++ b/assets/icons/completion_icons/enum.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/event.svg b/assets/icons/completion_icons/event.svg
new file mode 100644
index 0000000000000..cea1b30f5ac9b
--- /dev/null
+++ b/assets/icons/completion_icons/event.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/field_or_property.svg b/assets/icons/completion_icons/field_or_property.svg
new file mode 100644
index 0000000000000..aa7593d5832e9
--- /dev/null
+++ b/assets/icons/completion_icons/field_or_property.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/file.svg b/assets/icons/completion_icons/file.svg
new file mode 100644
index 0000000000000..59e8d4ff25d26
--- /dev/null
+++ b/assets/icons/completion_icons/file.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/folder.svg b/assets/icons/completion_icons/folder.svg
new file mode 100644
index 0000000000000..2e3a8f3f7fe98
--- /dev/null
+++ b/assets/icons/completion_icons/folder.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/function.svg b/assets/icons/completion_icons/function.svg
new file mode 100644
index 0000000000000..64f98a56eccc2
--- /dev/null
+++ b/assets/icons/completion_icons/function.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/interface.svg b/assets/icons/completion_icons/interface.svg
new file mode 100644
index 0000000000000..eedc6a8b72844
--- /dev/null
+++ b/assets/icons/completion_icons/interface.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/keyword.svg b/assets/icons/completion_icons/keyword.svg
new file mode 100644
index 0000000000000..d22137aafff22
--- /dev/null
+++ b/assets/icons/completion_icons/keyword.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/method.svg b/assets/icons/completion_icons/method.svg
new file mode 100644
index 0000000000000..4536249e95d3a
--- /dev/null
+++ b/assets/icons/completion_icons/method.svg
@@ -0,0 +1 @@
+
diff --git a/assets/icons/completion_icons/module.svg b/assets/icons/completion_icons/module.svg
new file mode 100644
index 0000000000000..4029d18d137d7
--- /dev/null
+++ b/assets/icons/completion_icons/module.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/operator.svg b/assets/icons/completion_icons/operator.svg
new file mode 100644
index 0000000000000..6b24a384befb2
--- /dev/null
+++ b/assets/icons/completion_icons/operator.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/reference.svg b/assets/icons/completion_icons/reference.svg
new file mode 100644
index 0000000000000..9837196dfc07a
--- /dev/null
+++ b/assets/icons/completion_icons/reference.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/snippet.svg b/assets/icons/completion_icons/snippet.svg
new file mode 100644
index 0000000000000..0682458a7d331
--- /dev/null
+++ b/assets/icons/completion_icons/snippet.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/struct.svg b/assets/icons/completion_icons/struct.svg
new file mode 100644
index 0000000000000..c288e175d26e3
--- /dev/null
+++ b/assets/icons/completion_icons/struct.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/text.svg b/assets/icons/completion_icons/text.svg
new file mode 100644
index 0000000000000..484e925f49244
--- /dev/null
+++ b/assets/icons/completion_icons/text.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/type_parameter.svg b/assets/icons/completion_icons/type_parameter.svg
new file mode 100644
index 0000000000000..e92ed669121fc
--- /dev/null
+++ b/assets/icons/completion_icons/type_parameter.svg
@@ -0,0 +1,3 @@
+
diff --git a/assets/icons/completion_icons/unit.svg b/assets/icons/completion_icons/unit.svg
new file mode 100644
index 0000000000000..ab0779f8a253c
--- /dev/null
+++ b/assets/icons/completion_icons/unit.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/value.svg b/assets/icons/completion_icons/value.svg
new file mode 100644
index 0000000000000..3593964e8bb50
--- /dev/null
+++ b/assets/icons/completion_icons/value.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/completion_icons/variable.svg b/assets/icons/completion_icons/variable.svg
new file mode 100644
index 0000000000000..dc19850a1a418
--- /dev/null
+++ b/assets/icons/completion_icons/variable.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index e05b20c37f281..9a3d176cf6655 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -82,7 +82,7 @@ use language::{
CodeLabel, Completion, CursorShape, Diagnostic, Documentation, IndentKind, IndentSize,
Language, OffsetRangeExt, Point, Selection, SelectionGoal, TransactionId,
};
-use lsp::{DiagnosticSeverity, LanguageServerId};
+use lsp::{CompletionItemKind, DiagnosticSeverity, LanguageServerId};
use mouse_context_menu::MouseContextMenu;
use movement::TextLayoutDetails;
use multi_buffer::ToOffsetUtf16;
@@ -965,6 +965,11 @@ impl CompletionsMenu {
documentation,
max_completion_len,
);
+
+ let completion_kind_icon =
+ completion_kind_icon(&completion.lsp_completion.kind)
+ .color(Color::Muted);
+
div()
.min_w(px(widest_completion_pixels + padding_width))
.max_w(max_completion_len + px(padding_width))
@@ -983,7 +988,13 @@ impl CompletionsMenu {
task.detach_and_log_err(cx)
}
}))
- .child(h_flex().overflow_hidden().child(completion_label))
+ .child(
+ h_flex()
+ .overflow_hidden()
+ .gap_1()
+ .child(completion_kind_icon)
+ .child(completion_label),
+ )
.end_slot(documentation_label),
)
})
@@ -1397,6 +1408,37 @@ impl CompletionsMenu {
}
}
+fn completion_kind_icon(completion_kind: &Option) -> Icon {
+ match completion_kind {
+ Some(CompletionItemKind::REFERENCE) => Icon::new(IconName::Reference),
+ Some(CompletionItemKind::METHOD) => Icon::new(IconName::Method),
+ Some(CompletionItemKind::FUNCTION) => Icon::new(IconName::Function),
+ Some(CompletionItemKind::CONSTRUCTOR) => Icon::new(IconName::Constructor),
+ Some(CompletionItemKind::FIELD) => Icon::new(IconName::Field),
+ Some(CompletionItemKind::VARIABLE) => Icon::new(IconName::Variable),
+ Some(CompletionItemKind::CLASS) => Icon::new(IconName::Class),
+ Some(CompletionItemKind::INTERFACE) => Icon::new(IconName::Interface),
+ Some(CompletionItemKind::MODULE) => Icon::new(IconName::Module),
+ Some(CompletionItemKind::PROPERTY) => Icon::new(IconName::Property),
+ Some(CompletionItemKind::UNIT) => Icon::new(IconName::Unit),
+ Some(CompletionItemKind::VALUE) => Icon::new(IconName::Value),
+ Some(CompletionItemKind::ENUM) => Icon::new(IconName::Enum),
+ Some(CompletionItemKind::KEYWORD) => Icon::new(IconName::Keyword),
+ Some(CompletionItemKind::SNIPPET) => Icon::new(IconName::Snippet),
+ Some(CompletionItemKind::COLOR) => Icon::new(IconName::Color),
+ Some(CompletionItemKind::FILE) => Icon::new(IconName::File),
+ Some(CompletionItemKind::FOLDER) => Icon::new(IconName::Folder),
+ Some(CompletionItemKind::ENUM_MEMBER) => Icon::new(IconName::Enum),
+ Some(CompletionItemKind::CONSTANT) => Icon::new(IconName::Constant),
+ Some(CompletionItemKind::STRUCT) => Icon::new(IconName::Struct),
+ Some(CompletionItemKind::EVENT) => Icon::new(IconName::Event),
+ Some(CompletionItemKind::OPERATOR) => Icon::new(IconName::Operator),
+ Some(CompletionItemKind::TYPE_PARAMETER) => Icon::new(IconName::TypeParameter),
+ Some(CompletionItemKind::TEXT) => Icon::new(IconName::Text),
+ _ => Icon::new(IconName::Text),
+ }
+}
+
#[derive(Clone)]
struct CodeActionsMenu {
actions: Arc<[CodeAction]>,
diff --git a/crates/ui/src/components/icon.rs b/crates/ui/src/components/icon.rs
index e637c64b8cfa5..7730ac848445a 100644
--- a/crates/ui/src/components/icon.rs
+++ b/crates/ui/src/components/icon.rs
@@ -116,6 +116,30 @@ pub enum IconName {
WholeWord,
XCircle,
ZedXCopilot,
+ Text,
+ Method,
+ Function,
+ Constructor,
+ Field,
+ Variable,
+ Class,
+ Interface,
+ Module,
+ Property,
+ Unit,
+ Value,
+ Enum,
+ Keyword,
+ Snippet,
+ Color,
+ FileKind,
+ Reference,
+ FolderKind,
+ Constant,
+ Struct,
+ Event,
+ Operator,
+ TypeParameter,
}
impl IconName {
@@ -212,6 +236,30 @@ impl IconName {
IconName::WholeWord => "icons/word_search.svg",
IconName::XCircle => "icons/error.svg",
IconName::ZedXCopilot => "icons/zed_x_copilot.svg",
+ IconName::Text => "icons/completion_icons/text.svg",
+ IconName::Unit => "icons/completion_icons/unit.svg",
+ IconName::Value => "icons/completion_icons/value.svg",
+ IconName::Enum => "icons/completion_icons/enum.svg",
+ IconName::Keyword => "icons/completion_icons/keyword.svg",
+ IconName::Snippet => "icons/completion_icons/snippet.svg",
+ IconName::Color => "icons/completion_icons/color.svg",
+ IconName::FileKind => "icons/completion_icons/file.svg",
+ IconName::Reference => "icons/completion_icons/reference.svg",
+ IconName::FolderKind => "icons/completion_icons/folder.svg",
+ IconName::Constant => "icons/completion_icons/constant.svg",
+ IconName::Struct => "icons/completion_icons/struct.svg",
+ IconName::Event => "icons/completion_icons/event.svg",
+ IconName::Operator => "icons/completion_icons/operator.svg",
+ IconName::Field => "icons/completion_icons/field_or_property.svg",
+ IconName::Variable => "icons/completion_icons/variable.svg",
+ IconName::Class => "icons/completion_icons/class.svg",
+ IconName::Interface => "icons/completion_icons/interface.svg",
+ IconName::Module => "icons/completion_icons/module.svg",
+ IconName::Property => "icons/completion_icons/field_or_property.svg",
+ IconName::Method => "icons/completion_icons/method.svg",
+ IconName::Function => "icons/completion_icons/function.svg",
+ IconName::Constructor => "icons/completion_icons/constructor.svg",
+ IconName::TypeParameter => "icons/completion_icons/type_parameter.svg",
}
}
}