Skip to content

Commit e4eb045

Browse files
committed
Merge pull request #105 from anubmat/issue_37
Solving Issue 37, changing scopes of major keywords, changing scope o…
2 parents 9a1c040 + bcb5d5f commit e4eb045

13 files changed

+309
-117
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ repository:
5353
patterns:
5454
- include: '#type-parameters'
5555
- include: '#type'
56-
- name: keyword.operator.ts
56+
- name: keyword.operator.comparison.ts
5757
match: '=\s*'
5858

5959
enum-declaration:
@@ -68,7 +68,7 @@ repository:
6868
name: meta.declaration.object.ts
6969
begin: '\b(?:(export)\s+)?\b(?:(abstract)\s+)?\b(?<!\.)(class|interface)\b'
7070
beginCaptures:
71-
'1': { name: storage.modifier.ts }
71+
'1': { name: storage.type.ts }
7272
'2': { name: storage.modifier.ts }
7373
'3': { name: storage.type.ts }
7474
end: (?<=\})
@@ -147,7 +147,7 @@ repository:
147147
begin: (?<!\()\s*((?:\b[a-zA-Z_$][\w$]*)|(?:\'[^']*\')|(?:\"[^"]*\"))\s*(\?\s*)?(?=(=|:))
148148
beginCaptures:
149149
'1': { name: variable.ts }
150-
'2': { name: keyword.operator.ts }
150+
'2': { name: keyword.others.ts }
151151
end: '(?=\}|;|,|$)|(?<=\})'
152152
patterns:
153153
- include: '#expression'
@@ -161,7 +161,7 @@ repository:
161161
'3': { name: storage.modifier.ts } # captures keyword (async)
162162
'4': { name: storage.type.property.ts } # captures keyword (get|set)
163163
'5': { name: keyword.operator.ts } # captures keyword (new)
164-
'6': { name: support.type.ts } # captures keyword (constructor)
164+
'6': { name: storage.type.ts } # captures keyword (constructor)
165165
'7': { name: entity.name.function.ts } # captures method name ([a-zA-Z_$][\.\w$]*)
166166
'8': { name: keyword.operator.ts } # captures (\??)
167167
end: '(?=\}|;|,)|(?<=\})'
@@ -182,7 +182,7 @@ repository:
182182
'3': { name: storage.modifier.ts } # captures keyword (async)
183183
'4': { name: storage.type.property.ts } # captures keyword (get|set)
184184
'5': { name: keyword.operator.ts } # captures keyword (new)
185-
'6': { name: support.type.ts } # captures keyword (constructor)
185+
'6': { name: storage.type.ts } # captures keyword (constructor)
186186
'7': { name: entity.name.function.ts } # captures method name ([a-zA-Z_$][\.\w$]*)
187187
'8': { name: keyword.operator.ts } # captures (\??)
188188

@@ -194,7 +194,7 @@ repository:
194194
end: (\])\s*(\?\s*)?|$
195195
endCaptures:
196196
'1': { name: meta.brace.square.ts }
197-
'2': { name: keyword.operator.ts }
197+
'2': { name: keyword.others.ts }
198198
patterns:
199199
- include: '#type-annotation'
200200
- include: '#indexer-parameter'
@@ -210,7 +210,7 @@ repository:
210210
name: meta.function.ts
211211
begin: \b(?:(export)\s+)?(?:(async)\s+)?(function\b)(?:\s+([a-zA-Z_$][\w$]*))?\s*
212212
beginCaptures:
213-
'1': { name: storage.modifier.ts }
213+
'1': { name: storage.type.ts }
214214
'2': { name: storage.modifier.ts }
215215
'3': { name: storage.type.function.ts }
216216
'4': { name: entity.name.function.ts }
@@ -227,7 +227,7 @@ repository:
227227
name: meta.function.overload.ts
228228
match: \b(?:(export)\s+)?(function\b)(?:\s+([a-zA-Z_$][\w$]*))?\s*
229229
captures:
230-
'1': { name: storage.modifier.ts }
230+
'1': { name: storage.type.ts }
231231
'2': { name: storage.type.function.ts }
232232
'3': { name: entity.name.function.ts }
233233

@@ -259,9 +259,9 @@ repository:
259259
match: '(?:\s*\b(public|private|protected)\b\s+)?(\.\.\.)?\s*([a-zA-Z_$][\w$]*)\s*(\??)'
260260
captures:
261261
'1': { name: storage.modifier.ts }
262-
'2': { name: keyword.operator.ts }
262+
'2': { name: keyword.others.ts }
263263
'3': { name: variable.parameter.ts }
264-
'4': { name: keyword.operator.ts }
264+
'4': { name: keyword.others.ts }
265265

266266
return-type:
267267
name: meta.return.type.ts
@@ -275,6 +275,7 @@ repository:
275275
begin: ":"
276276
end: (?=$|[,);\}\]]|//)|(?==[^>])|(?<=[\}>\]\)]|[a-zA-Z_$])\s*(?=\{)
277277
patterns:
278+
- include: '#expression-operator'
278279
- include: '#type'
279280
- include: '#string'
280281
- include: '#comment'
@@ -379,7 +380,7 @@ repository:
379380
variable-initializer:
380381
begin: (=)
381382
beginCaptures:
382-
'1': { name: keyword.operator.ts }
383+
'1': { name: keyword.operator.comparison.ts }
383384
end: (?=$|[,);=])
384385
patterns:
385386
- include: '#expression'
@@ -400,7 +401,9 @@ repository:
400401
- include: '#new-expr'
401402
- include: '#switch-statement'
402403
- include: '#block'
404+
- include: '#import-operator'
403405
- include: '#expression-operator'
406+
- include: '#imply-operator'
404407
- include: '#relational-operator'
405408
- include: '#arithmetic-operator'
406409
- include: '#logic-operator'
@@ -415,7 +418,7 @@ repository:
415418
name: switch-expression.expr.ts
416419
begin: \b(switch)\b\s*\(
417420
beginCaptures:
418-
'1': { name: keyword.operator.ts }
421+
'1': { name: keyword.control.ts }
419422
end: \)
420423
patterns:
421424
- include: '#expression'
@@ -449,7 +452,7 @@ repository:
449452
match: (?<=\()\s*\b(var|let|const)\s+([a-zA-Z_$][\w$]*)\s+(in|of)\b
450453
captures:
451454
'1': { name: storage.type.ts }
452-
'3': { name: keyword.operator.ts }
455+
'3': { name: keyword.others.ts }
453456

454457
function-call:
455458
name: functioncall.expr.ts
@@ -477,7 +480,7 @@ repository:
477480
name: new.expr.ts
478481
begin: '\b(new)\b'
479482
beginCaptures:
480-
'1': { name: keyword.operator.ts }
483+
'1': { name: keyword.others.ts }
481484
# new-expr ends just before any type or call arguments. Type arguments will be picked up by #cast.
482485
end: '(?=[(;]|$)'
483486
patterns:
@@ -492,8 +495,16 @@ repository:
492495
- include: '#expression'
493496

494497
expression-operator:
498+
name: keyword.others.ts
499+
match: \b(delete|in|instanceof|new|typeof|as|is|of)\b
500+
501+
imply-operator:
495502
name: keyword.operator.ts
496-
match: =>|\b(delete|export|import|from|in|instanceof|new|typeof|void|as)\b
503+
match: =>
504+
505+
import-operator:
506+
name: keyword.control.import.include.ts
507+
match: \b(import|from)\b
497508

498509
arithmetic-operator:
499510
name: keyword.operator.arithmetic.ts
@@ -513,7 +524,7 @@ repository:
513524

514525
storage-keyword:
515526
name: storage.type.ts
516-
match: \b(var|let|function|const|module|namespace)\b
527+
match: \b(var|let|function|const|module|namespace|void|export)\b
517528

518529
paren-expression:
519530
begin: \(
@@ -582,10 +593,10 @@ repository:
582593
name: template.element.ts
583594
begin: \$\{
584595
beginCaptures:
585-
'0': {name: keyword.operator.ts}
596+
'0': {name: keyword.others.ts}
586597
end: \}
587598
endCaptures:
588-
'0': {name: keyword.operator.ts}
599+
'0': {name: keyword.others.ts}
589600
patterns:
590601
- include: '#expression'
591602

TypeScript.tmLanguage

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,18 @@
367367
<key>include</key>
368368
<string>#block</string>
369369
</dict>
370+
<dict>
371+
<key>include</key>
372+
<string>#import-operator</string>
373+
</dict>
370374
<dict>
371375
<key>include</key>
372376
<string>#expression-operator</string>
373377
</dict>
378+
<dict>
379+
<key>include</key>
380+
<string>#imply-operator</string>
381+
</dict>
374382
<dict>
375383
<key>include</key>
376384
<string>#relational-operator</string>
@@ -412,9 +420,9 @@
412420
<key>expression-operator</key>
413421
<dict>
414422
<key>match</key>
415-
<string>=&gt;|\b(delete|export|import|from|in|instanceof|new|typeof|void|as)\b</string>
423+
<string>\b(delete|in|instanceof|new|typeof|as|is|of)\b</string>
416424
<key>name</key>
417-
<string>keyword.operator.ts</string>
425+
<string>keyword.others.ts</string>
418426
</dict>
419427
<key>field-declaration</key>
420428
<dict>
@@ -430,7 +438,7 @@
430438
<key>2</key>
431439
<dict>
432440
<key>name</key>
433-
<string>keyword.operator.ts</string>
441+
<string>keyword.others.ts</string>
434442
</dict>
435443
</dict>
436444
<key>end</key>
@@ -457,7 +465,7 @@
457465
<key>3</key>
458466
<dict>
459467
<key>name</key>
460-
<string>keyword.operator.ts</string>
468+
<string>keyword.others.ts</string>
461469
</dict>
462470
</dict>
463471
<key>match</key>
@@ -494,7 +502,7 @@
494502
<key>1</key>
495503
<dict>
496504
<key>name</key>
497-
<string>storage.modifier.ts</string>
505+
<string>storage.type.ts</string>
498506
</dict>
499507
<key>2</key>
500508
<dict>
@@ -551,7 +559,7 @@
551559
<key>1</key>
552560
<dict>
553561
<key>name</key>
554-
<string>storage.modifier.ts</string>
562+
<string>storage.type.ts</string>
555563
</dict>
556564
<key>2</key>
557565
<dict>
@@ -613,6 +621,20 @@
613621
</dict>
614622
</array>
615623
</dict>
624+
<key>imply-operator</key>
625+
<dict>
626+
<key>match</key>
627+
<string>=&gt;</string>
628+
<key>name</key>
629+
<string>keyword.operator.ts</string>
630+
</dict>
631+
<key>import-operator</key>
632+
<dict>
633+
<key>match</key>
634+
<string>\b(import|from)\b</string>
635+
<key>name</key>
636+
<string>keyword.control.import.include.ts</string>
637+
</dict>
616638
<key>indexer-declaration</key>
617639
<dict>
618640
<key>begin</key>
@@ -637,7 +659,7 @@
637659
<key>2</key>
638660
<dict>
639661
<key>name</key>
640-
<string>keyword.operator.ts</string>
662+
<string>keyword.others.ts</string>
641663
</dict>
642664
</dict>
643665
<key>name</key>
@@ -746,7 +768,7 @@
746768
<key>6</key>
747769
<dict>
748770
<key>name</key>
749-
<string>support.type.ts</string>
771+
<string>storage.type.ts</string>
750772
</dict>
751773
<key>7</key>
752774
<dict>
@@ -823,7 +845,7 @@
823845
<key>6</key>
824846
<dict>
825847
<key>name</key>
826-
<string>support.type.ts</string>
848+
<string>storage.type.ts</string>
827849
</dict>
828850
<key>7</key>
829851
<dict>
@@ -850,7 +872,7 @@
850872
<key>1</key>
851873
<dict>
852874
<key>name</key>
853-
<string>keyword.operator.ts</string>
875+
<string>keyword.others.ts</string>
854876
</dict>
855877
</dict>
856878
<key>end</key>
@@ -960,7 +982,7 @@
960982
<key>1</key>
961983
<dict>
962984
<key>name</key>
963-
<string>storage.modifier.ts</string>
985+
<string>storage.type.ts</string>
964986
</dict>
965987
<key>2</key>
966988
<dict>
@@ -1111,7 +1133,7 @@
11111133
<key>2</key>
11121134
<dict>
11131135
<key>name</key>
1114-
<string>keyword.operator.ts</string>
1136+
<string>keyword.others.ts</string>
11151137
</dict>
11161138
<key>3</key>
11171139
<dict>
@@ -1121,7 +1143,7 @@
11211143
<key>4</key>
11221144
<dict>
11231145
<key>name</key>
1124-
<string>keyword.operator.ts</string>
1146+
<string>keyword.others.ts</string>
11251147
</dict>
11261148
</dict>
11271149
<key>match</key>
@@ -1255,7 +1277,7 @@
12551277
<key>storage-keyword</key>
12561278
<dict>
12571279
<key>match</key>
1258-
<string>\b(var|let|function|const|module|namespace)\b</string>
1280+
<string>\b(var|let|function|const|module|namespace|void|export)\b</string>
12591281
<key>name</key>
12601282
<string>storage.type.ts</string>
12611283
</dict>
@@ -1307,7 +1329,7 @@
13071329
<key>1</key>
13081330
<dict>
13091331
<key>name</key>
1310-
<string>keyword.operator.ts</string>
1332+
<string>keyword.control.ts</string>
13111333
</dict>
13121334
</dict>
13131335
<key>end</key>
@@ -1403,7 +1425,7 @@
14031425
<key>0</key>
14041426
<dict>
14051427
<key>name</key>
1406-
<string>keyword.operator.ts</string>
1428+
<string>keyword.others.ts</string>
14071429
</dict>
14081430
</dict>
14091431
<key>end</key>
@@ -1413,7 +1435,7 @@
14131435
<key>0</key>
14141436
<dict>
14151437
<key>name</key>
1416-
<string>keyword.operator.ts</string>
1438+
<string>keyword.others.ts</string>
14171439
</dict>
14181440
</dict>
14191441
<key>name</key>
@@ -1483,6 +1505,10 @@
14831505
<string>meta.type.annotation.ts</string>
14841506
<key>patterns</key>
14851507
<array>
1508+
<dict>
1509+
<key>include</key>
1510+
<string>#expression-operator</string>
1511+
</dict>
14861512
<dict>
14871513
<key>include</key>
14881514
<string>#type</string>
@@ -1532,7 +1558,7 @@
15321558
<key>match</key>
15331559
<string>=\s*</string>
15341560
<key>name</key>
1535-
<string>keyword.operator.ts</string>
1561+
<string>keyword.operator.comparison.ts</string>
15361562
</dict>
15371563
</array>
15381564
</dict>
@@ -1840,7 +1866,7 @@
18401866
<key>1</key>
18411867
<dict>
18421868
<key>name</key>
1843-
<string>keyword.operator.ts</string>
1869+
<string>keyword.operator.comparison.ts</string>
18441870
</dict>
18451871
</dict>
18461872
<key>end</key>

0 commit comments

Comments
 (0)