@@ -61,10 +61,13 @@ impl LanguageServer {
6161 . kind
6262 . clone ( )
6363 . map ( |kind| match kind {
64- SuggestionKind :: Type ( t) => t. to_string ( ) ,
64+ SuggestionKind :: Value ( t) => t. to_string ( ) ,
6565 SuggestionKind :: Command ( cmd) => cmd. to_string ( ) ,
6666 SuggestionKind :: Module => "module" . to_string ( ) ,
6767 SuggestionKind :: Operator => "operator" . to_string ( ) ,
68+ SuggestionKind :: Variable => "variable" . to_string ( ) ,
69+ SuggestionKind :: Flag => "flag" . to_string ( ) ,
70+ _ => String :: new ( ) ,
6871 } )
6972 . map ( |s| CompletionItemLabelDetails {
7073 detail : None ,
@@ -103,18 +106,23 @@ impl LanguageServer {
103106 suggestion_kind : Option < SuggestionKind > ,
104107 ) -> Option < CompletionItemKind > {
105108 suggestion_kind. and_then ( |suggestion_kind| match suggestion_kind {
106- SuggestionKind :: Type ( t) => match t {
107- nu_protocol:: Type :: String => Some ( CompletionItemKind :: VARIABLE ) ,
109+ SuggestionKind :: Value ( t) => match t {
110+ nu_protocol:: Type :: String => Some ( CompletionItemKind :: VALUE ) ,
108111 _ => None ,
109112 } ,
113+ SuggestionKind :: CellPath => Some ( CompletionItemKind :: PROPERTY ) ,
110114 SuggestionKind :: Command ( c) => match c {
111115 nu_protocol:: engine:: CommandType :: Keyword => Some ( CompletionItemKind :: KEYWORD ) ,
112116 nu_protocol:: engine:: CommandType :: Builtin => Some ( CompletionItemKind :: FUNCTION ) ,
113117 nu_protocol:: engine:: CommandType :: External => Some ( CompletionItemKind :: INTERFACE ) ,
114118 _ => None ,
115119 } ,
120+ SuggestionKind :: Directory => Some ( CompletionItemKind :: FOLDER ) ,
121+ SuggestionKind :: File => Some ( CompletionItemKind :: FILE ) ,
122+ SuggestionKind :: Flag => Some ( CompletionItemKind :: FIELD ) ,
116123 SuggestionKind :: Module => Some ( CompletionItemKind :: MODULE ) ,
117124 SuggestionKind :: Operator => Some ( CompletionItemKind :: OPERATOR ) ,
125+ SuggestionKind :: Variable => Some ( CompletionItemKind :: VARIABLE ) ,
118126 } )
119127 }
120128}
@@ -180,7 +188,7 @@ mod tests {
180188 expected: serde_json:: json!( [
181189 {
182190 "label" : "$greeting" ,
183- "labelDetails" : { "description" : "string " } ,
191+ "labelDetails" : { "description" : "variable " } ,
184192 "textEdit" : {
185193 "newText" : "$greeting" ,
186194 "range" : { "start" : { "character" : 5 , "line" : 2 } , "end" : { "character" : 9 , "line" : 2 } }
@@ -236,9 +244,11 @@ mod tests {
236244 & serde_json:: json!( {
237245 "label" : "-s" ,
238246 "detail" : "test flag" ,
247+ "labelDetails" : { "description" : "flag" } ,
239248 "textEdit" : { "range" : { "start" : { "line" : 1 , "character" : 17 } , "end" : { "line" : 1 , "character" : 18 } , } ,
240249 "newText" : "-s"
241250 } ,
251+ "kind" : 5
242252 } )
243253 ) ) ;
244254
@@ -248,9 +258,11 @@ mod tests {
248258 & serde_json:: json!( {
249259 "label" : "--long" ,
250260 "detail" : "test flag" ,
261+ "labelDetails" : { "description" : "flag" } ,
251262 "textEdit" : { "range" : { "start" : { "line" : 2 , "character" : 19 } , "end" : { "line" : 2 , "character" : 22 } , } ,
252263 "newText" : "--long"
253264 } ,
265+ "kind" : 5
254266 } )
255267 ) ) ;
256268
@@ -259,9 +271,11 @@ mod tests {
259271 assert ! ( result_from_message( resp) . as_array( ) . unwrap( ) . contains(
260272 & serde_json:: json!( {
261273 "label" : "LICENSE" ,
274+ "labelDetails" : { "description" : "" } ,
262275 "textEdit" : { "range" : { "start" : { "line" : 2 , "character" : 17 } , "end" : { "line" : 2 , "character" : 18 } , } ,
263276 "newText" : "LICENSE"
264277 } ,
278+ "kind" : 17
265279 } )
266280 ) ) ;
267281
@@ -271,9 +285,11 @@ mod tests {
271285 & serde_json:: json!( {
272286 "label" : "-g" ,
273287 "detail" : "count indexes and split using grapheme clusters (all visible chars have length 1)" ,
288+ "labelDetails" : { "description" : "flag" } ,
274289 "textEdit" : { "range" : { "start" : { "line" : 10 , "character" : 33 } , "end" : { "line" : 10 , "character" : 34 } , } ,
275290 "newText" : "-g"
276291 } ,
292+ "kind" : 5
277293 } )
278294 ) ) ;
279295 }
@@ -328,9 +344,11 @@ mod tests {
328344 assert ! ( result_from_message( resp) . as_array( ) . unwrap( ) . contains(
329345 & serde_json:: json!( {
330346 "label" : "LICENSE" ,
347+ "labelDetails" : { "description" : "" } ,
331348 "textEdit" : { "range" : { "start" : { "line" : 5 , "character" : 3 } , "end" : { "line" : 5 , "character" : 4 } , } ,
332349 "newText" : "LICENSE"
333350 } ,
351+ "kind" : 17
334352 } )
335353 ) ) ;
336354 }
@@ -411,11 +429,12 @@ mod tests {
411429 expected: serde_json:: json!( [
412430 {
413431 "label" : "1" ,
414- "labelDetails " : { "description" : "record<1: string, 🤔🐘: table<baz: int>>" } ,
432+ "detail " : " string" ,
415433 "textEdit" : {
416434 "newText" : "1" ,
417435 "range" : { "start" : { "line" : 1 , "character" : 5 } , "end" : { "line" : 1 , "character" : 5 } }
418436 } ,
437+ "kind" : 10
419438 } ,
420439 ] )
421440 ) ;
@@ -426,11 +445,12 @@ mod tests {
426445 expected: serde_json:: json!( [
427446 {
428447 "label" : "baz" ,
429- "labelDetails " : { "description" : "table<baz: int>" } ,
448+ "detail " : " int" ,
430449 "textEdit" : {
431450 "newText" : "baz" ,
432451 "range" : { "start" : { "line" : 1 , "character" : 10 } , "end" : { "line" : 1 , "character" : 10 } }
433452 } ,
453+ "kind" : 10
434454 } ,
435455 ] )
436456 ) ;
0 commit comments