1
- import tmLanguage from "../src/grammars/lua-mta.tmLanguage.json" ;
1
+ let allFunctions = new Set ( ) ;
2
2
3
- function extractFunctions ( ) {
3
+ function extractFunctions ( tmLanguage ) {
4
4
const wantedScopes = new Set ( [
5
5
"support.function.mta-shared" ,
6
6
"support.function.mta-server" ,
7
7
"support.function.mta-client" ,
8
- ' keyword.mta'
8
+ " keyword.mta"
9
9
] ) ;
10
10
11
11
return tmLanguage . patterns ?. reduce ( ( funcs , { match, name } ) => {
@@ -16,8 +16,6 @@ function extractFunctions() {
16
16
} , [ ] ) || [ ] ;
17
17
}
18
18
19
- const allFunctions = new Set ( extractFunctions ( ) ) ;
20
-
21
19
function initKeywordLinker ( ) {
22
20
function onDomReady ( ) {
23
21
const spans = [
@@ -33,9 +31,15 @@ function initKeywordLinker() {
33
31
} ) ;
34
32
}
35
33
36
- document . readyState === "loading"
37
- ? window . addEventListener ( "DOMContentLoaded" , onDomReady )
38
- : onDomReady ( ) ;
34
+ fetch ( '/lua-mta.tmLanguage.json' )
35
+ . then ( res => res . json ( ) )
36
+ . then ( json => {
37
+ allFunctions = new Set ( extractFunctions ( json ) ) ;
38
+ document . readyState === "loading"
39
+ ? window . addEventListener ( "DOMContentLoaded" , onDomReady )
40
+ : onDomReady ( ) ;
41
+ } )
42
+ . catch ( err => console . error ( "Failed to load JSON grammar:" , err ) ) ;
39
43
}
40
44
41
45
initKeywordLinker ( ) ;
0 commit comments