1- import tmLanguage from "../src/grammars/lua-mta.tmLanguage.json" ;
1+ let allFunctions = new Set ( ) ;
22
3- function extractFunctions ( ) {
3+ function extractFunctions ( tmLanguage ) {
44 const wantedScopes = new Set ( [
55 "support.function.mta-shared" ,
66 "support.function.mta-server" ,
77 "support.function.mta-client" ,
8- ' keyword.mta'
8+ " keyword.mta"
99 ] ) ;
1010
1111 return tmLanguage . patterns ?. reduce ( ( funcs , { match, name } ) => {
@@ -16,8 +16,6 @@ function extractFunctions() {
1616 } , [ ] ) || [ ] ;
1717}
1818
19- const allFunctions = new Set ( extractFunctions ( ) ) ;
20-
2119function initKeywordLinker ( ) {
2220 function onDomReady ( ) {
2321 const spans = [
@@ -33,9 +31,15 @@ function initKeywordLinker() {
3331 } ) ;
3432 }
3533
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 ) ) ;
3943}
4044
4145initKeywordLinker ( ) ;
0 commit comments