Add LifetimeParam and ConstParam to CompletionItemKind

This commit is contained in:
Lukas Wirth 2021-01-19 20:21:56 +01:00
parent f647e134a7
commit 83e49200d8
4 changed files with 34 additions and 24 deletions

View File

@ -241,7 +241,7 @@ fn main() {
check(
r#"fn quux<const C: usize>() { $0 }"#,
expect![[r#"
tp C
cp C
fn quux() fn quux<const C: usize>()
"#]],
);

View File

@ -117,24 +117,26 @@ pub enum CompletionScore {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CompletionItemKind {
Snippet,
Keyword,
Module,
Function,
Attribute,
Binding,
BuiltinType,
Struct,
Const,
ConstParam,
Enum,
EnumVariant,
Binding,
Field,
Function,
Keyword,
LifetimeParam,
Macro,
Method,
Module,
Snippet,
Static,
Const,
Struct,
Trait,
TypeAlias,
Method,
TypeParam,
Macro,
Attribute,
UnresolvedReference,
}
@ -146,11 +148,13 @@ impl CompletionItemKind {
CompletionItemKind::Binding => "bn",
CompletionItemKind::BuiltinType => "bt",
CompletionItemKind::Const => "ct",
CompletionItemKind::ConstParam => "cp",
CompletionItemKind::Enum => "en",
CompletionItemKind::EnumVariant => "ev",
CompletionItemKind::Field => "fd",
CompletionItemKind::Function => "fn",
CompletionItemKind::Keyword => "kw",
CompletionItemKind::LifetimeParam => "lt",
CompletionItemKind::Macro => "ma",
CompletionItemKind::Method => "me",
CompletionItemKind::Module => "md",

View File

@ -208,7 +208,11 @@ impl<'a> Render<'a> {
ScopeDef::ModuleDef(Trait(..)) => CompletionItemKind::Trait,
ScopeDef::ModuleDef(TypeAlias(..)) => CompletionItemKind::TypeAlias,
ScopeDef::ModuleDef(BuiltinType(..)) => CompletionItemKind::BuiltinType,
ScopeDef::GenericParam(..) => CompletionItemKind::TypeParam,
ScopeDef::GenericParam(param) => match param {
hir::GenericParam::TypeParam(_) => CompletionItemKind::TypeParam,
hir::GenericParam::LifetimeParam(_) => CompletionItemKind::LifetimeParam,
hir::GenericParam::ConstParam(_) => CompletionItemKind::ConstParam,
},
ScopeDef::Local(..) => CompletionItemKind::Binding,
// (does this need its own kind?)
ScopeDef::AdtSelfType(..) | ScopeDef::ImplSelfType(..) => CompletionItemKind::TypeParam,

View File

@ -87,24 +87,26 @@ pub(crate) fn completion_item_kind(
completion_item_kind: CompletionItemKind,
) -> lsp_types::CompletionItemKind {
match completion_item_kind {
CompletionItemKind::Keyword => lsp_types::CompletionItemKind::Keyword,
CompletionItemKind::Snippet => lsp_types::CompletionItemKind::Snippet,
CompletionItemKind::Module => lsp_types::CompletionItemKind::Module,
CompletionItemKind::Function => lsp_types::CompletionItemKind::Function,
CompletionItemKind::Struct => lsp_types::CompletionItemKind::Struct,
CompletionItemKind::Attribute => lsp_types::CompletionItemKind::EnumMember,
CompletionItemKind::Binding => lsp_types::CompletionItemKind::Variable,
CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::Struct,
CompletionItemKind::Const => lsp_types::CompletionItemKind::Constant,
CompletionItemKind::ConstParam => lsp_types::CompletionItemKind::TypeParameter,
CompletionItemKind::Enum => lsp_types::CompletionItemKind::Enum,
CompletionItemKind::EnumVariant => lsp_types::CompletionItemKind::EnumMember,
CompletionItemKind::BuiltinType => lsp_types::CompletionItemKind::Struct,
CompletionItemKind::Binding => lsp_types::CompletionItemKind::Variable,
CompletionItemKind::Field => lsp_types::CompletionItemKind::Field,
CompletionItemKind::Function => lsp_types::CompletionItemKind::Function,
CompletionItemKind::Keyword => lsp_types::CompletionItemKind::Keyword,
CompletionItemKind::LifetimeParam => lsp_types::CompletionItemKind::TypeParameter,
CompletionItemKind::Macro => lsp_types::CompletionItemKind::Method,
CompletionItemKind::Method => lsp_types::CompletionItemKind::Method,
CompletionItemKind::Module => lsp_types::CompletionItemKind::Module,
CompletionItemKind::Snippet => lsp_types::CompletionItemKind::Snippet,
CompletionItemKind::Static => lsp_types::CompletionItemKind::Value,
CompletionItemKind::Struct => lsp_types::CompletionItemKind::Struct,
CompletionItemKind::Trait => lsp_types::CompletionItemKind::Interface,
CompletionItemKind::TypeAlias => lsp_types::CompletionItemKind::Struct,
CompletionItemKind::Const => lsp_types::CompletionItemKind::Constant,
CompletionItemKind::Static => lsp_types::CompletionItemKind::Value,
CompletionItemKind::Method => lsp_types::CompletionItemKind::Method,
CompletionItemKind::TypeParam => lsp_types::CompletionItemKind::TypeParameter,
CompletionItemKind::Macro => lsp_types::CompletionItemKind::Method,
CompletionItemKind::Attribute => lsp_types::CompletionItemKind::EnumMember,
CompletionItemKind::UnresolvedReference => lsp_types::CompletionItemKind::Reference,
}
}