aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-01-19 19:21:56 +0000
committerLukas Wirth <[email protected]>2021-01-19 19:25:29 +0000
commit83e49200d82dccda54bbf376bba5a9c75da14cab (patch)
tree48b14cd545e44b95ad086a2476c95cd68c32fd49
parentf647e134a785245579da3de04235887a5e958c9b (diff)
Add LifetimeParam and ConstParam to CompletionItemKind
-rw-r--r--crates/completion/src/completions/unqualified_path.rs2
-rw-r--r--crates/completion/src/item.rs24
-rw-r--r--crates/completion/src/render.rs6
-rw-r--r--crates/rust-analyzer/src/to_proto.rs26
4 files changed, 34 insertions, 24 deletions
diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs
index 809e1645a..860c774c1 100644
--- a/crates/completion/src/completions/unqualified_path.rs
+++ b/crates/completion/src/completions/unqualified_path.rs
@@ -241,7 +241,7 @@ fn main() {
241 check( 241 check(
242 r#"fn quux<const C: usize>() { $0 }"#, 242 r#"fn quux<const C: usize>() { $0 }"#,
243 expect![[r#" 243 expect![[r#"
244 tp C 244 cp C
245 fn quux() fn quux<const C: usize>() 245 fn quux() fn quux<const C: usize>()
246 "#]], 246 "#]],
247 ); 247 );
diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs
index 4147853e7..ecf581be2 100644
--- a/crates/completion/src/item.rs
+++ b/crates/completion/src/item.rs
@@ -117,24 +117,26 @@ pub enum CompletionScore {
117 117
118#[derive(Debug, Clone, Copy, PartialEq, Eq)] 118#[derive(Debug, Clone, Copy, PartialEq, Eq)]
119pub enum CompletionItemKind { 119pub enum CompletionItemKind {
120 Snippet, 120 Attribute,
121 Keyword, 121 Binding,
122 Module,
123 Function,
124 BuiltinType, 122 BuiltinType,
125 Struct, 123 Const,
124 ConstParam,
126 Enum, 125 Enum,
127 EnumVariant, 126 EnumVariant,
128 Binding,
129 Field, 127 Field,
128 Function,
129 Keyword,
130 LifetimeParam,
131 Macro,
132 Method,
133 Module,
134 Snippet,
130 Static, 135 Static,
131 Const, 136 Struct,
132 Trait, 137 Trait,
133 TypeAlias, 138 TypeAlias,
134 Method,
135 TypeParam, 139 TypeParam,
136 Macro,
137 Attribute,
138 UnresolvedReference, 140 UnresolvedReference,
139} 141}
140 142
@@ -146,11 +148,13 @@ impl CompletionItemKind {
146 CompletionItemKind::Binding => "bn", 148 CompletionItemKind::Binding => "bn",
147 CompletionItemKind::BuiltinType => "bt", 149 CompletionItemKind::BuiltinType => "bt",
148 CompletionItemKind::Const => "ct", 150 CompletionItemKind::Const => "ct",
151 CompletionItemKind::ConstParam => "cp",
149 CompletionItemKind::Enum => "en", 152 CompletionItemKind::Enum => "en",
150 CompletionItemKind::EnumVariant => "ev", 153 CompletionItemKind::EnumVariant => "ev",
151 CompletionItemKind::Field => "fd", 154 CompletionItemKind::Field => "fd",
152 CompletionItemKind::Function => "fn", 155 CompletionItemKind::Function => "fn",
153 CompletionItemKind::Keyword => "kw", 156 CompletionItemKind::Keyword => "kw",
157 CompletionItemKind::LifetimeParam => "lt",
154 CompletionItemKind::Macro => "ma", 158 CompletionItemKind::Macro => "ma",
155 CompletionItemKind::Method => "me", 159 CompletionItemKind::Method => "me",
156 CompletionItemKind::Module => "md", 160 CompletionItemKind::Module => "md",
diff --git a/crates/completion/src/render.rs b/crates/completion/src/render.rs
index 4f622d28a..68556c8ce 100644
--- a/crates/completion/src/render.rs
+++ b/crates/completion/src/render.rs
@@ -208,7 +208,11 @@ impl<'a> Render<'a> {
208 ScopeDef::ModuleDef(Trait(..)) => CompletionItemKind::Trait, 208 ScopeDef::ModuleDef(Trait(..)) => CompletionItemKind::Trait,
209 ScopeDef::ModuleDef(TypeAlias(..)) => CompletionItemKind::TypeAlias, 209 ScopeDef::ModuleDef(TypeAlias(..)) => CompletionItemKind::TypeAlias,
210 ScopeDef::ModuleDef(BuiltinType(..)) => CompletionItemKind::BuiltinType, 210 ScopeDef::ModuleDef(BuiltinType(..)) => CompletionItemKind::BuiltinType,
211 ScopeDef::GenericParam(..) => CompletionItemKind::TypeParam, 211 ScopeDef::GenericParam(param) => match param {
212 hir::GenericParam::TypeParam(_) => CompletionItemKind::TypeParam,
213 hir::GenericParam::LifetimeParam(_) => CompletionItemKind::LifetimeParam,
214 hir::GenericParam::ConstParam(_) => CompletionItemKind::ConstParam,
215 },
212 ScopeDef::Local(..) => CompletionItemKind::Binding, 216 ScopeDef::Local(..) => CompletionItemKind::Binding,
213 // (does this need its own kind?) 217 // (does this need its own kind?)
214 ScopeDef::AdtSelfType(..) | ScopeDef::ImplSelfType(..) => CompletionItemKind::TypeParam, 218 ScopeDef::AdtSelfType(..) | ScopeDef::ImplSelfType(..) => CompletionItemKind::TypeParam,
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index 0e3550002..9fd32a8c7 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -87,24 +87,26 @@ pub(crate) fn completion_item_kind(
87 completion_item_kind: CompletionItemKind, 87 completion_item_kind: CompletionItemKind,
88) -> lsp_types::CompletionItemKind { 88) -> lsp_types::CompletionItemKind {
89 match completion_item_kind { 89 match completion_item_kind {
90 CompletionItemKind::Keyword => lsp_types::CompletionItemKind::Keyword, 90 CompletionItemKind::Attribute => lsp_types::CompletionItemKind::EnumMember,
91 CompletionItemKind::Snippet => lsp_types::CompletionItemKind::Snippet, 91 CompletionItemKind::Binding => lsp_types::CompletionItemKind::Variable,
92 CompletionItemKind::Module => lsp_types::CompletionItemKind::Module, 92 CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::Struct,
93 CompletionItemKind::Function => lsp_types::CompletionItemKind::Function, 93 CompletionItemKind::Const => lsp_types::CompletionItemKind::Constant,
94 CompletionItemKind::Struct => lsp_types::CompletionItemKind::Struct, 94 CompletionItemKind::ConstParam => lsp_types::CompletionItemKind::TypeParameter,
95 CompletionItemKind::Enum => lsp_types::CompletionItemKind::Enum, 95 CompletionItemKind::Enum => lsp_types::CompletionItemKind::Enum,
96 CompletionItemKind::EnumVariant => lsp_types::CompletionItemKind::EnumMember, 96 CompletionItemKind::EnumVariant => lsp_types::CompletionItemKind::EnumMember,
97 CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::Struct,
98 CompletionItemKind::Binding => lsp_types::CompletionItemKind::Variable,
99 CompletionItemKind::Field => lsp_types::CompletionItemKind::Field, 97 CompletionItemKind::Field => lsp_types::CompletionItemKind::Field,
98 CompletionItemKind::Function => lsp_types::CompletionItemKind::Function,
99 CompletionItemKind::Keyword => lsp_types::CompletionItemKind::Keyword,
100 CompletionItemKind::LifetimeParam => lsp_types::CompletionItemKind::TypeParameter,
101 CompletionItemKind::Macro => lsp_types::CompletionItemKind::Method,
102 CompletionItemKind::Method => lsp_types::CompletionItemKind::Method,
103 CompletionItemKind::Module => lsp_types::CompletionItemKind::Module,
104 CompletionItemKind::Snippet => lsp_types::CompletionItemKind::Snippet,
105 CompletionItemKind::Static => lsp_types::CompletionItemKind::Value,
106 CompletionItemKind::Struct => lsp_types::CompletionItemKind::Struct,
100 CompletionItemKind::Trait => lsp_types::CompletionItemKind::Interface, 107 CompletionItemKind::Trait => lsp_types::CompletionItemKind::Interface,
101 CompletionItemKind::TypeAlias => lsp_types::CompletionItemKind::Struct, 108 CompletionItemKind::TypeAlias => lsp_types::CompletionItemKind::Struct,
102 CompletionItemKind::Const => lsp_types::CompletionItemKind::Constant,
103 CompletionItemKind::Static => lsp_types::CompletionItemKind::Value,
104 CompletionItemKind::Method => lsp_types::CompletionItemKind::Method,
105 CompletionItemKind::TypeParam => lsp_types::CompletionItemKind::TypeParameter, 109 CompletionItemKind::TypeParam => lsp_types::CompletionItemKind::TypeParameter,
106 CompletionItemKind::Macro => lsp_types::CompletionItemKind::Method,
107 CompletionItemKind::Attribute => lsp_types::CompletionItemKind::EnumMember,
108 CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::Reference, 110 CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::Reference,
109 } 111 }
110} 112}