Skip to content

Commit 5f842cc

Browse files
committed
Update mta-keywords_linker.js
1 parent 85a710a commit 5f842cc

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

web/public/mta-keywords_linker.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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-
2119
function 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

4145
initKeywordLinker();

0 commit comments

Comments
 (0)