@@ -8,12 +8,13 @@ const __filename = fileURLToPath(import.meta.url);
8
8
const __dirname = path . dirname ( __filename ) ;
9
9
10
10
const functionsDir = path . resolve ( __dirname , '../../functions' ) ;
11
+ const elementsDir = path . resolve ( __dirname , '../../elements' ) ;
12
+ const typesDir = path . resolve ( __dirname , '../../types' ) ;
13
+
11
14
const basePath = path . resolve ( __dirname , './lua-base.tmLanguage.json' ) ;
12
15
const outputPath = path . resolve ( __dirname , '../src/grammars/lua-mta.tmLanguage.json' ) ;
13
16
const publicPath = path . resolve ( __dirname , '../public/grammars/lua-mta.tmLanguage.json' ) ;
14
17
15
- const mtaKeywords = [ 'string' , 'bool' , 'boolean' , 'number' , 'int' , 'float' , 'element' , 'player' , 'vehicle' , 'ped' , 'object' , 'building' ] ;
16
-
17
18
function extractFunctionsWithScope ( yamlContent ) {
18
19
if ( yamlContent . shared ?. name ) {
19
20
return [ { name : yamlContent . shared . name , scope : 'support.function.mta-shared' } ] ;
@@ -40,16 +41,24 @@ async function generateTmLanguage() {
40
41
items . flatMap ( extractFunctionsWithScope ) . forEach ( ( { name, scope } ) => functionsMap [ scope ] . add ( name ) ) ;
41
42
} ) ;
42
43
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
+
43
50
const patterns = Object . entries ( functionsMap )
44
51
. filter ( ( [ , namesSet ] ) => namesSet . size > 0 )
45
52
. map ( ( [ scope , namesSet ] ) => ( {
46
53
match : `\\b(${ Array . from ( namesSet ) . join ( '|' ) } )\\b` ,
47
54
name : scope ,
48
55
} ) ) ;
49
56
50
- if ( mtaKeywords . length > 0 ) {
57
+ const allKeywords = [ ...elementKeywords , ...typeKeywords ] ;
58
+
59
+ if ( allKeywords . length > 0 ) {
51
60
patterns . push ( {
52
- match : `\\b(${ mtaKeywords . join ( '|' ) } )\\b` ,
61
+ match : `\\b(${ allKeywords . join ( '|' ) } )\\b` ,
53
62
name : 'keyword.mta' ,
54
63
} ) ;
55
64
}
0 commit comments