@@ -23,6 +23,7 @@ import {
23
23
SemanticToken ,
24
24
Severity ,
25
25
type Workspace ,
26
+ CompletionKind ,
26
27
} from "ty_wasm" ;
27
28
import { FileId , ReadonlyFiles } from "../Playground" ;
28
29
import { isPythonFile } from "./Files" ;
@@ -276,7 +277,10 @@ class PlaygroundServer
276
277
suggestions : completions . map ( ( completion , i ) => ( {
277
278
label : completion . name ,
278
279
sortText : String ( i ) . padStart ( digitsLength , "0" ) ,
279
- kind : CompletionItemKind . Variable ,
280
+ kind :
281
+ completion . kind == null
282
+ ? CompletionItemKind . Variable
283
+ : mapCompletionKind ( completion . kind ) ,
280
284
insertText : completion . name ,
281
285
// TODO(micha): It's unclear why this field is required for monaco but not VS Code.
282
286
// and omitting it works just fine? The LSP doesn't expose this information right now
@@ -616,3 +620,58 @@ function generateMonacoTokens(
616
620
617
621
return { data : Uint32Array . from ( result ) } ;
618
622
}
623
+
624
+ function mapCompletionKind ( kind : CompletionKind ) : CompletionItemKind {
625
+ switch ( kind ) {
626
+ case CompletionKind . Text :
627
+ return CompletionItemKind . Text ;
628
+ case CompletionKind . Method :
629
+ return CompletionItemKind . Method ;
630
+ case CompletionKind . Function :
631
+ return CompletionItemKind . Function ;
632
+ case CompletionKind . Constructor :
633
+ return CompletionItemKind . Constructor ;
634
+ case CompletionKind . Field :
635
+ return CompletionItemKind . Field ;
636
+ case CompletionKind . Variable :
637
+ return CompletionItemKind . Variable ;
638
+ case CompletionKind . Class :
639
+ return CompletionItemKind . Class ;
640
+ case CompletionKind . Interface :
641
+ return CompletionItemKind . Interface ;
642
+ case CompletionKind . Module :
643
+ return CompletionItemKind . Module ;
644
+ case CompletionKind . Property :
645
+ return CompletionItemKind . Property ;
646
+ case CompletionKind . Unit :
647
+ return CompletionItemKind . Unit ;
648
+ case CompletionKind . Value :
649
+ return CompletionItemKind . Value ;
650
+ case CompletionKind . Enum :
651
+ return CompletionItemKind . Enum ;
652
+ case CompletionKind . Keyword :
653
+ return CompletionItemKind . Keyword ;
654
+ case CompletionKind . Snippet :
655
+ return CompletionItemKind . Snippet ;
656
+ case CompletionKind . Color :
657
+ return CompletionItemKind . Color ;
658
+ case CompletionKind . File :
659
+ return CompletionItemKind . File ;
660
+ case CompletionKind . Reference :
661
+ return CompletionItemKind . Reference ;
662
+ case CompletionKind . Folder :
663
+ return CompletionItemKind . Folder ;
664
+ case CompletionKind . EnumMember :
665
+ return CompletionItemKind . EnumMember ;
666
+ case CompletionKind . Constant :
667
+ return CompletionItemKind . Constant ;
668
+ case CompletionKind . Struct :
669
+ return CompletionItemKind . Struct ;
670
+ case CompletionKind . Event :
671
+ return CompletionItemKind . Event ;
672
+ case CompletionKind . Operator :
673
+ return CompletionItemKind . Operator ;
674
+ case CompletionKind . TypeParameter :
675
+ return CompletionItemKind . TypeParameter ;
676
+ }
677
+ }
0 commit comments