Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/handlers/completion/item.rs')
-rw-r--r--helix-term/src/handlers/completion/item.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/helix-term/src/handlers/completion/item.rs b/helix-term/src/handlers/completion/item.rs
new file mode 100644
index 00000000..bcd35cd5
--- /dev/null
+++ b/helix-term/src/handlers/completion/item.rs
@@ -0,0 +1,41 @@
+use helix_lsp::{lsp, LanguageServerId};
+
+#[derive(Debug, PartialEq, Clone)]
+pub struct LspCompletionItem {
+ pub item: lsp::CompletionItem,
+ pub provider: LanguageServerId,
+ pub resolved: bool,
+}
+
+#[derive(Debug, PartialEq, Clone)]
+pub enum CompletionItem {
+ Lsp(LspCompletionItem),
+ Other(helix_core::CompletionItem),
+}
+
+impl PartialEq<CompletionItem> for LspCompletionItem {
+ fn eq(&self, other: &CompletionItem) -> bool {
+ match other {
+ CompletionItem::Lsp(other) => self == other,
+ _ => false,
+ }
+ }
+}
+
+impl PartialEq<CompletionItem> for helix_core::CompletionItem {
+ fn eq(&self, other: &CompletionItem) -> bool {
+ match other {
+ CompletionItem::Other(other) => self == other,
+ _ => false,
+ }
+ }
+}
+
+impl CompletionItem {
+ pub fn preselect(&self) -> bool {
+ match self {
+ CompletionItem::Lsp(LspCompletionItem { item, .. }) => item.preselect.unwrap_or(false),
+ CompletionItem::Other(_) => false,
+ }
+ }
+}