@@ -5,9 +5,12 @@ const wantedScopes = new Set([
55 "support.function.mta-server" ,
66 "support.function.mta-client" ,
77 "keyword.mta" ,
8- "support.function.library.lua"
8+ "support.function.library.lua" ,
9+ "support.function.lua"
910] ) ;
1011
12+ const luaGlobals = [ "_G" , "_VERSION" , "math.pi" , "math.huge" ] ;
13+
1114function extractFunctions ( tmLanguage , textContent ) {
1215 const result = new Set ( ) ;
1316
@@ -42,6 +45,14 @@ function extractFunctions(tmLanguage, textContent) {
4245 } ) ;
4346 } ) ;
4447 return ;
48+ } else if ( name === "support.function.lua" ) {
49+ const funcsMatch = [ ...match . matchAll ( / \( ( [ ^ ) ] + ) \) / g) ] . map ( m => m [ 1 ] ) . filter ( s => s . includes ( "|" ) ) . pop ( ) || "" ;
50+ const funcs = funcsMatch . split ( "|" ) ;
51+ funcs . forEach ( fn => {
52+ result . add ( fn ) ;
53+ luaGlobals . push ( fn ) ;
54+ } ) ;
55+ return ;
4556 } else {
4657 const matches = match . match ( / \\ b \( ( [ ^ ) ] + ) \) \\ b / ) ?. [ 1 ] ?. split ( "|" ) || [ ] ;
4758 matches . forEach ( w => result . add ( w ) ) ;
@@ -50,6 +61,8 @@ function extractFunctions(tmLanguage, textContent) {
5061 }
5162 } ) ;
5263
64+ luaGlobals . forEach ( name => result . add ( name ) ) ;
65+
5366 return Array . from ( result ) ;
5467}
5568
@@ -65,7 +78,7 @@ function initKeywordLinker() {
6578 if ( allFunctions . has ( text ) ) {
6679 let url = `/reference/${ text } ` ;
6780 const [ lib ] = text . split ( "." ) ;
68- if ( [ "string" , "math" , "table" , "os" , "debug" , "coroutine" ] . includes ( lib ) ) {
81+ if ( [ "string" , "math" , "table" , "os" , "debug" , "coroutine" ] . includes ( lib ) || luaGlobals . includes ( text ) ) {
6982 url = `https://www.lua.org/manual/5.1/manual.html#pdf-${ text } ` ;
7083 }
7184
0 commit comments