From 4d2bceee553d337809c19639349948f1afaf951f Mon Sep 17 00:00:00 2001 From: Felix Zeller Date: Mon, 1 Apr 2024 17:28:51 -0400 Subject: [PATCH 1/9] add completion kind icons --- assets/icons/completion_icons/class.svg | 1 + assets/icons/completion_icons/color.svg | 1 + assets/icons/completion_icons/constant.svg | 1 + assets/icons/completion_icons/constructor.svg | 1 + assets/icons/completion_icons/enum.svg | 1 + assets/icons/completion_icons/event.svg | 1 + assets/icons/completion_icons/field_or_property.svg | 1 + assets/icons/completion_icons/file.svg | 1 + assets/icons/completion_icons/folder.svg | 1 + assets/icons/completion_icons/function.svg | 1 + assets/icons/completion_icons/interface.svg | 1 + assets/icons/completion_icons/keyword.svg | 1 + assets/icons/completion_icons/method.svg | 1 + assets/icons/completion_icons/module.svg | 1 + assets/icons/completion_icons/operator.svg | 1 + assets/icons/completion_icons/reference.svg | 1 + assets/icons/completion_icons/snippet.svg | 1 + assets/icons/completion_icons/struct.svg | 1 + assets/icons/completion_icons/text.svg | 1 + assets/icons/completion_icons/type_parameter.svg | 3 +++ assets/icons/completion_icons/unit.svg | 1 + assets/icons/completion_icons/value.svg | 1 + assets/icons/completion_icons/variable.svg | 1 + 23 files changed, 25 insertions(+) create mode 100644 assets/icons/completion_icons/class.svg create mode 100644 assets/icons/completion_icons/color.svg create mode 100644 assets/icons/completion_icons/constant.svg create mode 100644 assets/icons/completion_icons/constructor.svg create mode 100644 assets/icons/completion_icons/enum.svg create mode 100644 assets/icons/completion_icons/event.svg create mode 100644 assets/icons/completion_icons/field_or_property.svg create mode 100644 assets/icons/completion_icons/file.svg create mode 100644 assets/icons/completion_icons/folder.svg create mode 100644 assets/icons/completion_icons/function.svg create mode 100644 assets/icons/completion_icons/interface.svg create mode 100644 assets/icons/completion_icons/keyword.svg create mode 100644 assets/icons/completion_icons/method.svg create mode 100644 assets/icons/completion_icons/module.svg create mode 100644 assets/icons/completion_icons/operator.svg create mode 100644 assets/icons/completion_icons/reference.svg create mode 100644 assets/icons/completion_icons/snippet.svg create mode 100644 assets/icons/completion_icons/struct.svg create mode 100644 assets/icons/completion_icons/text.svg create mode 100644 assets/icons/completion_icons/type_parameter.svg create mode 100644 assets/icons/completion_icons/unit.svg create mode 100644 assets/icons/completion_icons/value.svg create mode 100644 assets/icons/completion_icons/variable.svg 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..b0fe498982877 --- /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 From 735d08ed8311be10cbb2bc696f82fa9fd0550beb Mon Sep 17 00:00:00 2001 From: Felix Zeller Date: Mon, 1 Apr 2024 17:29:16 -0400 Subject: [PATCH 2/9] add icons to IconName type --- crates/ui/src/components/icon.rs | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/crates/ui/src/components/icon.rs b/crates/ui/src/components/icon.rs index e637c64b8cfa5..ff0285a9186f0 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" } } } From 464415e72fec4530b4e2d7eed28058e2271f4305 Mon Sep 17 00:00:00 2001 From: Felix Zeller Date: Mon, 1 Apr 2024 17:29:28 -0400 Subject: [PATCH 3/9] display icons --- crates/editor/src/editor.rs | 42 +++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index e05b20c37f281..9a76845066d76 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; @@ -121,8 +121,7 @@ use theme::{ ThemeColors, ThemeSettings, }; use ui::{ - h_flex, prelude::*, ButtonSize, ButtonStyle, IconButton, IconName, IconSize, ListItem, Popover, - Tooltip, + h_flex, prelude::*, ButtonSize, ButtonStyle, IconButton, IconName, IconSize, KeyIcon, ListItem, Popover, Tooltip }; use util::{maybe, post_inc, RangeExt, ResultExt, TryFutureExt}; use workspace::Toast; @@ -965,6 +964,9 @@ impl CompletionsMenu { documentation, max_completion_len, ); + + let completion_kind_icon = completion_kind_icon(&completion.lsp_completion.kind); + div() .min_w(px(widest_completion_pixels + padding_width)) .max_w(max_completion_len + px(padding_width)) @@ -983,7 +985,7 @@ 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 +1399,38 @@ 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), + } +} + + #[derive(Clone)] struct CodeActionsMenu { actions: Arc<[CodeAction]>, From 0db6abd29ad741b806cead2715f2f2c812faa72d Mon Sep 17 00:00:00 2001 From: Felix Zeller Date: Mon, 1 Apr 2024 17:52:06 -0400 Subject: [PATCH 4/9] change the event icon --- assets/icons/completion_icons/event.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/icons/completion_icons/event.svg b/assets/icons/completion_icons/event.svg index b0fe498982877..cea1b30f5ac9b 100644 --- a/assets/icons/completion_icons/event.svg +++ b/assets/icons/completion_icons/event.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From 7f61cf0fbc6c23a45abe709177ac559eac7d8c05 Mon Sep 17 00:00:00 2001 From: Felix Zeller Date: Mon, 1 Apr 2024 17:58:50 -0400 Subject: [PATCH 5/9] Formatting --- crates/editor/src/editor.rs | 16 +++++++++++----- crates/ui/src/components/icon.rs | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 9a76845066d76..67e295af90679 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -121,7 +121,8 @@ use theme::{ ThemeColors, ThemeSettings, }; use ui::{ - h_flex, prelude::*, ButtonSize, ButtonStyle, IconButton, IconName, IconSize, KeyIcon, ListItem, Popover, Tooltip + h_flex, prelude::*, ButtonSize, ButtonStyle, IconButton, IconName, IconSize, KeyIcon, ListItem, + Popover, Tooltip, }; use util::{maybe, post_inc, RangeExt, ResultExt, TryFutureExt}; use workspace::Toast; @@ -965,7 +966,8 @@ impl CompletionsMenu { max_completion_len, ); - let completion_kind_icon = completion_kind_icon(&completion.lsp_completion.kind); + let completion_kind_icon = + completion_kind_icon(&completion.lsp_completion.kind); div() .min_w(px(widest_completion_pixels + padding_width)) @@ -985,7 +987,13 @@ impl CompletionsMenu { task.detach_and_log_err(cx) } })) - .child(h_flex().overflow_hidden().gap_1().child(completion_kind_icon).child(completion_label)) + .child( + h_flex() + .overflow_hidden() + .gap_1() + .child(completion_kind_icon) + .child(completion_label), + ) .end_slot(documentation_label), ) }) @@ -1399,7 +1407,6 @@ impl CompletionsMenu { } } - fn completion_kind_icon(completion_kind: &Option) -> Icon { match completion_kind { Some(CompletionItemKind::REFERENCE) => Icon::new(IconName::Reference), @@ -1430,7 +1437,6 @@ fn completion_kind_icon(completion_kind: &Option) -> Icon { } } - #[derive(Clone)] struct CodeActionsMenu { actions: Arc<[CodeAction]>, diff --git a/crates/ui/src/components/icon.rs b/crates/ui/src/components/icon.rs index ff0285a9186f0..7730ac848445a 100644 --- a/crates/ui/src/components/icon.rs +++ b/crates/ui/src/components/icon.rs @@ -139,7 +139,7 @@ pub enum IconName { Struct, Event, Operator, - TypeParameter + TypeParameter, } impl IconName { @@ -259,7 +259,7 @@ impl IconName { 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" + IconName::TypeParameter => "icons/completion_icons/type_parameter.svg", } } } From e32834b0e695de934a880248d581f292656e269e Mon Sep 17 00:00:00 2001 From: Felix Zeller Date: Mon, 1 Apr 2024 18:01:47 -0400 Subject: [PATCH 6/9] remove unused icon struct --- crates/editor/src/editor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 67e295af90679..7d7bacd2e7c6a 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -121,7 +121,7 @@ use theme::{ ThemeColors, ThemeSettings, }; use ui::{ - h_flex, prelude::*, ButtonSize, ButtonStyle, IconButton, IconName, IconSize, KeyIcon, ListItem, + h_flex, prelude::*, ButtonSize, ButtonStyle, IconButton, IconName, IconSize, ListItem, Popover, Tooltip, }; use util::{maybe, post_inc, RangeExt, ResultExt, TryFutureExt}; From e16b13bb0bf5547c16fdcc3328c737c70046ae1d Mon Sep 17 00:00:00 2001 From: Felix Zeller Date: Mon, 1 Apr 2024 18:07:19 -0400 Subject: [PATCH 7/9] praise be to clippy --- crates/editor/src/editor.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 7d7bacd2e7c6a..cf2397d24043f 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1433,7 +1433,8 @@ fn completion_kind_icon(completion_kind: &Option) -> Icon { 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), + Some(CompletionItemKind::TEXT) => Icon::new(IconName::Text), + _ => Icon::new(IconName::Text), } } From 47da4dec0bfffbcb5b11be714f07731a68f82e3c Mon Sep 17 00:00:00 2001 From: Felix Zeller Date: Mon, 1 Apr 2024 18:07:56 -0400 Subject: [PATCH 8/9] and don't forget about cargo fmt --- crates/editor/src/editor.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index cf2397d24043f..ba2d100f00fcc 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -121,8 +121,8 @@ use theme::{ ThemeColors, ThemeSettings, }; use ui::{ - h_flex, prelude::*, ButtonSize, ButtonStyle, IconButton, IconName, IconSize, ListItem, - Popover, Tooltip, + h_flex, prelude::*, ButtonSize, ButtonStyle, IconButton, IconName, IconSize, ListItem, Popover, + Tooltip, }; use util::{maybe, post_inc, RangeExt, ResultExt, TryFutureExt}; use workspace::Toast; From c99db5dbc4d464f409cdba4d7a11f4852641a087 Mon Sep 17 00:00:00 2001 From: Felix Zeller Date: Mon, 1 Apr 2024 19:19:25 -0400 Subject: [PATCH 9/9] use a muted color for the icons --- crates/editor/src/editor.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index ba2d100f00fcc..9a3d176cf6655 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -967,7 +967,8 @@ impl CompletionsMenu { ); let completion_kind_icon = - completion_kind_icon(&completion.lsp_completion.kind); + completion_kind_icon(&completion.lsp_completion.kind) + .color(Color::Muted); div() .min_w(px(widest_completion_pixels + padding_width))