diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index b2f4cd228b0..6fd1578801e 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs @@ -30,7 +30,7 @@ use crate::{ }; pub use crate::{ - completion::{CompletionItem, InsertText}, + completion::{CompletionItem, CompletionItemKind, InsertText}, }; pub use ra_editor::{ FileSymbol, Fold, FoldKind, HighlightedRange, LineIndex, Runnable, RunnableKind, StructureNode, diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 973e0915edd..6f770ec696c 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -2,7 +2,7 @@ use languageserver_types::{ self, Location, Position, Range, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, InsertTextFormat, }; -use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileEdit, FilePosition, CompletionItem, InsertText}; +use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileEdit, FilePosition, CompletionItem, CompletionItemKind, InsertText}; use ra_editor::{LineCol, LineIndex}; use ra_text_edit::{AtomTextEdit, TextEdit}; use ra_syntax::{SyntaxKind, TextRange, TextUnit}; @@ -45,6 +45,18 @@ impl Conv for SyntaxKind { } } +impl Conv for CompletionItemKind { + type Output = ::languageserver_types::CompletionItemKind; + + fn conv(self) -> ::Output { + use ::languageserver_types::CompletionItemKind::*; + match self { + CompletionItemKind::Keyword => Keyword, + CompletionItemKind::Snippet => Snippet, + } + } +} + impl Conv for CompletionItem { type Output = ::languageserver_types::CompletionItem; @@ -52,6 +64,7 @@ impl Conv for CompletionItem { let mut res = ::languageserver_types::CompletionItem { label: self.label().to_string(), filter_text: Some(self.lookup().to_string()), + kind: self.kind().map(|it| it.conv()), ..Default::default() }; match self.insert_text() {