@@ -8,12 +8,13 @@ const __filename = fileURLToPath(import.meta.url);
88const __dirname = path . dirname ( __filename ) ;
99
1010const functionsDir = path . resolve ( __dirname , '../../functions' ) ;
11+ const elementsDir = path . resolve ( __dirname , '../../elements' ) ;
12+ const typesDir = path . resolve ( __dirname , '../../types' ) ;
13+
1114const basePath = path . resolve ( __dirname , './lua-base.tmLanguage.json' ) ;
1215const outputPath = path . resolve ( __dirname , '../src/grammars/lua-mta.tmLanguage.json' ) ;
1316const publicPath = path . resolve ( __dirname , '../public/grammars/lua-mta.tmLanguage.json' ) ;
1417
15- const mtaKeywords = [ 'string' , 'bool' , 'boolean' , 'number' , 'int' , 'float' , 'element' , 'player' , 'vehicle' , 'ped' , 'object' , 'building' ] ;
16-
1718function extractFunctionsWithScope ( yamlContent ) {
1819 if ( yamlContent . shared ?. name ) {
1920 return [ { name : yamlContent . shared . name , scope : 'support.function.mta-shared' } ] ;
@@ -40,16 +41,24 @@ async function generateTmLanguage() {
4041 items . flatMap ( extractFunctionsWithScope ) . forEach ( ( { name, scope } ) => functionsMap [ scope ] . add ( name ) ) ;
4142 } ) ;
4243
44+ const elementFiles = await glob ( '**/*.yaml' , { cwd : elementsDir , absolute : true } ) ;
45+ const elementKeywords = elementFiles . map ( file => path . basename ( file , '.yaml' ) ) ;
46+
47+ const typeFiles = await glob ( '**/*.yaml' , { cwd : typesDir , absolute : true } ) ;
48+ const typeKeywords = typeFiles . map ( file => path . basename ( file , '.yaml' ) ) ;
49+
4350 const patterns = Object . entries ( functionsMap )
4451 . filter ( ( [ , namesSet ] ) => namesSet . size > 0 )
4552 . map ( ( [ scope , namesSet ] ) => ( {
4653 match : `\\b(${ Array . from ( namesSet ) . join ( '|' ) } )\\b` ,
4754 name : scope ,
4855 } ) ) ;
4956
50- if ( mtaKeywords . length > 0 ) {
57+ const allKeywords = [ ...elementKeywords , ...typeKeywords ] ;
58+
59+ if ( allKeywords . length > 0 ) {
5160 patterns . push ( {
52- match : `\\b(${ mtaKeywords . join ( '|' ) } )\\b` ,
61+ match : `\\b(${ allKeywords . join ( '|' ) } )\\b` ,
5362 name : 'keyword.mta' ,
5463 } ) ;
5564 }
0 commit comments