1
- import { parser } from "@lezer/rust"
1
+ import { parser } from "@lezer/rust" ;
2
2
import {
3
3
continuedIndent ,
4
4
indentNodeProp ,
5
5
foldNodeProp ,
6
6
foldInside ,
7
7
LRLanguage ,
8
8
LanguageSupport
9
- } from "@codemirror/language"
9
+ } from "@codemirror/language" ;
10
+ import { completeFromList } from "@codemirror/autocomplete" ;
11
+ import { rustCompletions } from "./keywords"
10
12
11
13
const rustLanguage = LRLanguage . define ( {
12
14
name : "rust" ,
@@ -19,20 +21,20 @@ const rustLanguage = LRLanguage.define({
19
21
"Statement MatchArm" : continuedIndent ( )
20
22
} ) ,
21
23
foldNodeProp . add ( type => {
22
- if ( / ( B l o c k | e d T o k e n s | L i s t ) $ / . test ( type . name ) ) return foldInside
23
- if ( type . name == "BlockComment" ) return tree => ( { from : tree . from + 2 , to : tree . to - 2 } )
24
- return undefined
24
+ if ( / ( B l o c k | e d T o k e n s | L i s t ) $ / . test ( type . name ) ) return foldInside ;
25
+ if ( type . name == "BlockComment" ) return tree => ( { from : tree . from + 2 , to : tree . to - 2 } ) ;
26
+ return undefined ;
25
27
} )
26
28
]
27
29
} ) ,
28
30
languageData : {
29
31
commentTokens : { line : "//" , block : { open : "/*" , close : "*/" } } ,
30
32
indentOnInput : / ^ \s * (?: \{ | \} ) $ / ,
31
- closeBrackets : { stringPrefixes : [ "b" , "r" , "br" ] }
33
+ closeBrackets : { stringPrefixes : [ "b" , "r" , "br" ] } ,
34
+ autocomplete : completeFromList ( rustCompletions ) ,
32
35
}
33
- } )
36
+ } ) ;
34
37
35
38
export function rust ( ) {
36
- return new LanguageSupport ( rustLanguage )
39
+ return new LanguageSupport ( rustLanguage ) ;
37
40
}
38
-
0 commit comments