react-native-codepad-lang-tsx 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,762 @@
1
+ ; inherited from typescript
2
+ ; inherited from ecma
3
+ ; Types
4
+ ; Javascript
5
+ ; Variables
6
+ ;-----------
7
+ (identifier) @variable
8
+
9
+ ; Properties
10
+ ;-----------
11
+ (property_identifier) @variable.member
12
+
13
+ (shorthand_property_identifier) @variable.member
14
+
15
+ (private_property_identifier) @variable.member
16
+
17
+ (object_pattern
18
+ (shorthand_property_identifier_pattern) @variable)
19
+
20
+ (object_pattern
21
+ (object_assignment_pattern
22
+ (shorthand_property_identifier_pattern) @variable))
23
+
24
+ ; Special identifiers
25
+ ;--------------------
26
+ ((identifier) @type
27
+ (#match? @type "^[A-Z]"))
28
+
29
+ ((identifier) @constant
30
+ (#match? @constant "^_*[A-Z][A-Z0-9_]*$"))
31
+
32
+ ((shorthand_property_identifier) @constant
33
+ (#match? @constant "^_*[A-Z][A-Z0-9_]*$"))
34
+
35
+ ((identifier) @variable.builtin
36
+ (#any-of? @variable.builtin "arguments" "module" "console" "window" "document"))
37
+
38
+ ((identifier) @type.builtin
39
+ (#any-of? @type.builtin
40
+ "Object" "Function" "Boolean" "Symbol" "Number" "Math" "Date" "String" "RegExp" "Map" "Set"
41
+ "WeakMap" "WeakSet" "Promise" "Array" "Int8Array" "Uint8Array" "Uint8ClampedArray" "Int16Array"
42
+ "Uint16Array" "Int32Array" "Uint32Array" "Float32Array" "Float64Array" "ArrayBuffer" "DataView"
43
+ "Error" "EvalError" "InternalError" "RangeError" "ReferenceError" "SyntaxError" "TypeError"
44
+ "URIError"))
45
+
46
+ (statement_identifier) @label
47
+
48
+ ; Function and method definitions
49
+ ;--------------------------------
50
+ (function_expression
51
+ name: (identifier) @function)
52
+
53
+ (function_declaration
54
+ name: (identifier) @function)
55
+
56
+ (generator_function
57
+ name: (identifier) @function)
58
+
59
+ (generator_function_declaration
60
+ name: (identifier) @function)
61
+
62
+ (method_definition
63
+ name: [
64
+ (property_identifier)
65
+ (private_property_identifier)
66
+ ] @function.method)
67
+
68
+ (method_definition
69
+ name: (property_identifier) @constructor
70
+ (#eq? @constructor "constructor"))
71
+
72
+ (pair
73
+ key: (property_identifier) @function.method
74
+ value: (function_expression))
75
+
76
+ (pair
77
+ key: (property_identifier) @function.method
78
+ value: (arrow_function))
79
+
80
+ (assignment_expression
81
+ left: (member_expression
82
+ property: (property_identifier) @function.method)
83
+ right: (arrow_function))
84
+
85
+ (assignment_expression
86
+ left: (member_expression
87
+ property: (property_identifier) @function.method)
88
+ right: (function_expression))
89
+
90
+ (variable_declarator
91
+ name: (identifier) @function
92
+ value: (arrow_function))
93
+
94
+ (variable_declarator
95
+ name: (identifier) @function
96
+ value: (function_expression))
97
+
98
+ (assignment_expression
99
+ left: (identifier) @function
100
+ right: (arrow_function))
101
+
102
+ (assignment_expression
103
+ left: (identifier) @function
104
+ right: (function_expression))
105
+
106
+ ; Function and method calls
107
+ ;--------------------------
108
+ (call_expression
109
+ function: (identifier) @function.call)
110
+
111
+ (call_expression
112
+ function: (member_expression
113
+ property: [
114
+ (property_identifier)
115
+ (private_property_identifier)
116
+ ] @function.method.call))
117
+
118
+ (call_expression
119
+ function: (await_expression
120
+ (identifier) @function.call))
121
+
122
+ (call_expression
123
+ function: (await_expression
124
+ (member_expression
125
+ property: [
126
+ (property_identifier)
127
+ (private_property_identifier)
128
+ ] @function.method.call)))
129
+
130
+ ; Builtins
131
+ ;---------
132
+ ((identifier) @module.builtin
133
+ (#eq? @module.builtin "Intl"))
134
+
135
+ ((identifier) @function.builtin
136
+ (#any-of? @function.builtin
137
+ "eval" "isFinite" "isNaN" "parseFloat" "parseInt" "decodeURI" "decodeURIComponent" "encodeURI"
138
+ "encodeURIComponent" "require"))
139
+
140
+ ; Constructor
141
+ ;------------
142
+ (new_expression
143
+ constructor: (identifier) @constructor)
144
+
145
+ ; Decorators
146
+ ;----------
147
+ (decorator
148
+ "@" @attribute
149
+ (identifier) @attribute)
150
+
151
+ (decorator
152
+ "@" @attribute
153
+ (call_expression
154
+ (identifier) @attribute))
155
+
156
+ (decorator
157
+ "@" @attribute
158
+ (member_expression
159
+ (property_identifier) @attribute))
160
+
161
+ (decorator
162
+ "@" @attribute
163
+ (call_expression
164
+ (member_expression
165
+ (property_identifier) @attribute)))
166
+
167
+ ; Literals
168
+ ;---------
169
+ [
170
+ (this)
171
+ (super)
172
+ ] @variable.builtin
173
+
174
+ ((identifier) @variable.builtin
175
+ (#eq? @variable.builtin "self"))
176
+
177
+ [
178
+ (true)
179
+ (false)
180
+ ] @boolean
181
+
182
+ [
183
+ (null)
184
+ (undefined)
185
+ ] @constant.builtin
186
+
187
+ [
188
+ (comment)
189
+ (html_comment)
190
+ ] @comment @spell
191
+
192
+ ((comment) @comment.documentation
193
+ (#match? @comment.documentation "^/[*][*][^*].*[*]/$"))
194
+
195
+ (hash_bang_line) @keyword.directive
196
+
197
+ ((string_fragment) @keyword.directive
198
+ (#eq? @keyword.directive "use strict"))
199
+
200
+ (string) @string
201
+
202
+ (template_string) @string
203
+
204
+ (escape_sequence) @string.escape
205
+
206
+ (regex_pattern) @string.regexp
207
+
208
+ (regex_flags) @character.special
209
+
210
+ (regex
211
+ "/" @punctuation.bracket) ; Regex delimiters
212
+
213
+ (number) @number
214
+
215
+ ((identifier) @number
216
+ (#any-of? @number "NaN" "Infinity"))
217
+
218
+ ; Punctuation
219
+ ;------------
220
+ [
221
+ ";"
222
+ "."
223
+ ","
224
+ ":"
225
+ ] @punctuation.delimiter
226
+
227
+ [
228
+ "--"
229
+ "-"
230
+ "-="
231
+ "&&"
232
+ "+"
233
+ "++"
234
+ "+="
235
+ "&="
236
+ "/="
237
+ "**="
238
+ "<<="
239
+ "<"
240
+ "<="
241
+ "<<"
242
+ "="
243
+ "=="
244
+ "==="
245
+ "!="
246
+ "!=="
247
+ "=>"
248
+ ">"
249
+ ">="
250
+ ">>"
251
+ "||"
252
+ "%"
253
+ "%="
254
+ "*"
255
+ "**"
256
+ ">>>"
257
+ "&"
258
+ "|"
259
+ "^"
260
+ "??"
261
+ "*="
262
+ ">>="
263
+ ">>>="
264
+ "^="
265
+ "|="
266
+ "&&="
267
+ "||="
268
+ "??="
269
+ "..."
270
+ ] @operator
271
+
272
+ (binary_expression
273
+ "/" @operator)
274
+
275
+ (ternary_expression
276
+ [
277
+ "?"
278
+ ":"
279
+ ] @keyword.conditional.ternary)
280
+
281
+ (unary_expression
282
+ [
283
+ "!"
284
+ "~"
285
+ "-"
286
+ "+"
287
+ ] @operator)
288
+
289
+ (unary_expression
290
+ [
291
+ "delete"
292
+ "void"
293
+ ] @keyword.operator)
294
+
295
+ [
296
+ "("
297
+ ")"
298
+ "["
299
+ "]"
300
+ "{"
301
+ "}"
302
+ ] @punctuation.bracket
303
+
304
+ (template_substitution
305
+ [
306
+ "${"
307
+ "}"
308
+ ] @punctuation.special) @none
309
+
310
+ ; Imports
311
+ ;----------
312
+ (namespace_import
313
+ "*" @character.special
314
+ (identifier) @module)
315
+
316
+ (namespace_export
317
+ "*" @character.special
318
+ (identifier) @module)
319
+
320
+ (export_statement
321
+ "*" @character.special)
322
+
323
+ ; Keywords
324
+ ;----------
325
+ [
326
+ "if"
327
+ "else"
328
+ "switch"
329
+ "case"
330
+ ] @keyword.conditional
331
+
332
+ [
333
+ "import"
334
+ "from"
335
+ "as"
336
+ "export"
337
+ ] @keyword.import
338
+
339
+ [
340
+ "for"
341
+ "of"
342
+ "do"
343
+ "while"
344
+ "continue"
345
+ ] @keyword.repeat
346
+
347
+ [
348
+ "break"
349
+ "const"
350
+ "debugger"
351
+ "extends"
352
+ "get"
353
+ "let"
354
+ "set"
355
+ "static"
356
+ "target"
357
+ "var"
358
+ "with"
359
+ ] @keyword
360
+
361
+ "class" @keyword.type
362
+
363
+ [
364
+ "async"
365
+ "await"
366
+ ] @keyword.coroutine
367
+
368
+ [
369
+ "return"
370
+ "yield"
371
+ ] @keyword.return
372
+
373
+ "function" @keyword.function
374
+
375
+ [
376
+ "new"
377
+ "delete"
378
+ "in"
379
+ "instanceof"
380
+ "typeof"
381
+ ] @keyword.operator
382
+
383
+ [
384
+ "throw"
385
+ "try"
386
+ "catch"
387
+ "finally"
388
+ ] @keyword.exception
389
+
390
+ (export_statement
391
+ "default" @keyword)
392
+
393
+ (switch_default
394
+ "default" @keyword.conditional)
395
+
396
+
397
+ "require" @keyword.import
398
+
399
+ (import_require_clause
400
+ source: (string) @string.special.url)
401
+
402
+ [
403
+ "declare"
404
+ "implements"
405
+ "type"
406
+ "override"
407
+ "module"
408
+ "asserts"
409
+ "infer"
410
+ "is"
411
+ "using"
412
+ ] @keyword
413
+
414
+ [
415
+ "namespace"
416
+ "interface"
417
+ "enum"
418
+ ] @keyword.type
419
+
420
+ [
421
+ "keyof"
422
+ "satisfies"
423
+ ] @keyword.operator
424
+
425
+ (as_expression
426
+ "as" @keyword.operator)
427
+
428
+ (mapped_type_clause
429
+ "as" @keyword.operator)
430
+
431
+ [
432
+ "abstract"
433
+ "private"
434
+ "protected"
435
+ "public"
436
+ "readonly"
437
+ ] @keyword.modifier
438
+
439
+ ; types
440
+ (type_identifier) @type
441
+
442
+ (predefined_type) @type.builtin
443
+
444
+ (import_statement
445
+ "type"
446
+ (import_clause
447
+ (named_imports
448
+ (import_specifier
449
+ name: (identifier) @type))))
450
+
451
+ (template_literal_type) @string
452
+
453
+ (non_null_expression
454
+ "!" @operator)
455
+
456
+ ; punctuation
457
+ (type_arguments
458
+ [
459
+ "<"
460
+ ">"
461
+ ] @punctuation.bracket)
462
+
463
+ (type_parameters
464
+ [
465
+ "<"
466
+ ">"
467
+ ] @punctuation.bracket)
468
+
469
+ (object_type
470
+ [
471
+ "{|"
472
+ "|}"
473
+ ] @punctuation.bracket)
474
+
475
+ (union_type
476
+ "|" @punctuation.delimiter)
477
+
478
+ (intersection_type
479
+ "&" @punctuation.delimiter)
480
+
481
+ (type_annotation
482
+ ":" @punctuation.delimiter)
483
+
484
+ (type_predicate_annotation
485
+ ":" @punctuation.delimiter)
486
+
487
+ (index_signature
488
+ ":" @punctuation.delimiter)
489
+
490
+ (omitting_type_annotation
491
+ "-?:" @punctuation.delimiter)
492
+
493
+ (adding_type_annotation
494
+ "+?:" @punctuation.delimiter)
495
+
496
+ (opting_type_annotation
497
+ "?:" @punctuation.delimiter)
498
+
499
+ "?." @punctuation.delimiter
500
+
501
+ (abstract_method_signature
502
+ "?" @punctuation.special)
503
+
504
+ (method_signature
505
+ "?" @punctuation.special)
506
+
507
+ (method_definition
508
+ "?" @punctuation.special)
509
+
510
+ (property_signature
511
+ "?" @punctuation.special)
512
+
513
+ (optional_parameter
514
+ "?" @punctuation.special)
515
+
516
+ (optional_type
517
+ "?" @punctuation.special)
518
+
519
+ (public_field_definition
520
+ [
521
+ "?"
522
+ "!"
523
+ ] @punctuation.special)
524
+
525
+ (flow_maybe_type
526
+ "?" @punctuation.special)
527
+
528
+ (template_type
529
+ [
530
+ "${"
531
+ "}"
532
+ ] @punctuation.special)
533
+
534
+ (conditional_type
535
+ [
536
+ "?"
537
+ ":"
538
+ ] @keyword.conditional.ternary)
539
+
540
+ ; Parameters
541
+ (required_parameter
542
+ pattern: (identifier) @variable.parameter)
543
+
544
+ (optional_parameter
545
+ pattern: (identifier) @variable.parameter)
546
+
547
+ (required_parameter
548
+ (rest_pattern
549
+ (identifier) @variable.parameter))
550
+
551
+ ; ({ a }) => null
552
+ (required_parameter
553
+ (object_pattern
554
+ (shorthand_property_identifier_pattern) @variable.parameter))
555
+
556
+ ; ({ a = b }) => null
557
+ (required_parameter
558
+ (object_pattern
559
+ (object_assignment_pattern
560
+ (shorthand_property_identifier_pattern) @variable.parameter)))
561
+
562
+ ; ({ a: b }) => null
563
+ (required_parameter
564
+ (object_pattern
565
+ (pair_pattern
566
+ value: (identifier) @variable.parameter)))
567
+
568
+ ; ([ a ]) => null
569
+ (required_parameter
570
+ (array_pattern
571
+ (identifier) @variable.parameter))
572
+
573
+ ; a => null
574
+ (arrow_function
575
+ parameter: (identifier) @variable.parameter)
576
+
577
+ ; global declaration
578
+ (ambient_declaration
579
+ "global" @module)
580
+
581
+ ; function signatures
582
+ (ambient_declaration
583
+ (function_signature
584
+ name: (identifier) @function))
585
+
586
+ ; method signatures
587
+ (method_signature
588
+ name: (_) @function.method)
589
+
590
+ (abstract_method_signature
591
+ name: (property_identifier) @function.method)
592
+
593
+ ; property signatures
594
+ (property_signature
595
+ name: (property_identifier) @function.method
596
+ type: (type_annotation
597
+ [
598
+ (union_type
599
+ (parenthesized_type
600
+ (function_type)))
601
+ (function_type)
602
+ ]))
603
+
604
+ ; inherited from jsx
605
+ (jsx_element
606
+ open_tag: (jsx_opening_element
607
+ [
608
+ "<"
609
+ ">"
610
+ ] @tag.delimiter))
611
+
612
+ (jsx_element
613
+ close_tag: (jsx_closing_element
614
+ [
615
+ "</"
616
+ ">"
617
+ ] @tag.delimiter))
618
+
619
+ (jsx_self_closing_element
620
+ [
621
+ "<"
622
+ "/>"
623
+ ] @tag.delimiter)
624
+
625
+ (jsx_attribute
626
+ (property_identifier) @tag.attribute)
627
+
628
+ (jsx_opening_element
629
+ name: (identifier) @tag.builtin)
630
+
631
+ (jsx_closing_element
632
+ name: (identifier) @tag.builtin)
633
+
634
+ (jsx_self_closing_element
635
+ name: (identifier) @tag.builtin)
636
+
637
+ (jsx_opening_element
638
+ ((identifier) @tag
639
+ (#match? @tag "^[A-Z]")))
640
+
641
+ ; Handle the dot operator effectively - <My.Component>
642
+ (jsx_opening_element
643
+ (member_expression
644
+ (identifier) @tag.builtin
645
+ (property_identifier) @tag))
646
+
647
+ (jsx_closing_element
648
+ ((identifier) @tag
649
+ (#match? @tag "^[A-Z]")))
650
+
651
+ ; Handle the dot operator effectively - </My.Component>
652
+ (jsx_closing_element
653
+ (member_expression
654
+ (identifier) @tag.builtin
655
+ (property_identifier) @tag))
656
+
657
+ (jsx_self_closing_element
658
+ ((identifier) @tag
659
+ (#match? @tag "^[A-Z]")))
660
+
661
+ ; Handle the dot operator effectively - <My.Component />
662
+ (jsx_self_closing_element
663
+ (member_expression
664
+ (identifier) @tag.builtin
665
+ (property_identifier) @tag))
666
+
667
+ (html_character_reference) @tag
668
+
669
+ (jsx_text) @none @spell
670
+
671
+ (html_character_reference) @character.special
672
+
673
+ ((jsx_element
674
+ (jsx_opening_element
675
+ name: (identifier) @_tag)
676
+ (jsx_text) @markup.heading)
677
+ (#eq? @_tag "title"))
678
+
679
+ ((jsx_element
680
+ (jsx_opening_element
681
+ name: (identifier) @_tag)
682
+ (jsx_text) @markup.heading.1)
683
+ (#eq? @_tag "h1"))
684
+
685
+ ((jsx_element
686
+ (jsx_opening_element
687
+ name: (identifier) @_tag)
688
+ (jsx_text) @markup.heading.2)
689
+ (#eq? @_tag "h2"))
690
+
691
+ ((jsx_element
692
+ (jsx_opening_element
693
+ name: (identifier) @_tag)
694
+ (jsx_text) @markup.heading.3)
695
+ (#eq? @_tag "h3"))
696
+
697
+ ((jsx_element
698
+ (jsx_opening_element
699
+ name: (identifier) @_tag)
700
+ (jsx_text) @markup.heading.4)
701
+ (#eq? @_tag "h4"))
702
+
703
+ ((jsx_element
704
+ (jsx_opening_element
705
+ name: (identifier) @_tag)
706
+ (jsx_text) @markup.heading.5)
707
+ (#eq? @_tag "h5"))
708
+
709
+ ((jsx_element
710
+ (jsx_opening_element
711
+ name: (identifier) @_tag)
712
+ (jsx_text) @markup.heading.6)
713
+ (#eq? @_tag "h6"))
714
+
715
+ ((jsx_element
716
+ (jsx_opening_element
717
+ name: (identifier) @_tag)
718
+ (jsx_text) @markup.strong)
719
+ (#any-of? @_tag "strong" "b"))
720
+
721
+ ((jsx_element
722
+ (jsx_opening_element
723
+ name: (identifier) @_tag)
724
+ (jsx_text) @markup.italic)
725
+ (#any-of? @_tag "em" "i"))
726
+
727
+ ((jsx_element
728
+ (jsx_opening_element
729
+ name: (identifier) @_tag)
730
+ (jsx_text) @markup.strikethrough)
731
+ (#any-of? @_tag "s" "del"))
732
+
733
+ ((jsx_element
734
+ (jsx_opening_element
735
+ name: (identifier) @_tag)
736
+ (jsx_text) @markup.underline)
737
+ (#eq? @_tag "u"))
738
+
739
+ ((jsx_element
740
+ (jsx_opening_element
741
+ name: (identifier) @_tag)
742
+ (jsx_text) @markup.raw)
743
+ (#any-of? @_tag "code" "kbd"))
744
+
745
+ ((jsx_element
746
+ (jsx_opening_element
747
+ name: (identifier) @_tag)
748
+ (jsx_text) @markup.link.label)
749
+ (#eq? @_tag "a"))
750
+
751
+ ((jsx_attribute
752
+ (property_identifier) @_attr
753
+ (string
754
+ (string_fragment) @string.special.url))
755
+ (#any-of? @_attr "href" "src"))
756
+
757
+ ((jsx_element) @_jsx_element
758
+ (#set! @_jsx_element bo.commentstring "{/* %s */}"))
759
+
760
+ ((jsx_attribute) @_jsx_attribute
761
+ (#set! @_jsx_attribute bo.commentstring "// %s"))
762
+