Skip to content

Commit 429cf30

Browse files
committed
Merge pull request #173 from zhengbli/issue162
Fix syntax highlight issues for object types
2 parents f13f673 + 95c0e02 commit 429cf30

File tree

2 files changed

+152
-136
lines changed

2 files changed

+152
-136
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repository:
2121

2222
control-statement:
2323
name: keyword.control.ts
24-
match: \b(break|catch|continue|declare|do|else|finally|for|if|return|switch|throw|try|while)\b
24+
match: \b(break|catch|continue|declare|do|else|finally|for|if|return|switch|throw|try|while|with|super)\b
2525

2626
switch-case:
2727
name: case.expr.ts
@@ -100,7 +100,7 @@ repository:
100100
- include: '#static-modifier'
101101
- include: '#property-accessor'
102102

103-
object-type:
103+
type-object:
104104
name: meta.object.type.ts
105105
begin: \{
106106
beginCaptures:
@@ -225,21 +225,20 @@ repository:
225225
type-annotation:
226226
name: meta.type.annotation.ts
227227
begin: ":"
228-
end: (?=$|[,);\}\]]|//)|(?==[^>])|(?<=\}|[a-zA-Z_$]|>)\s*(?=\{)
228+
end: (?=$|[,);\}\]]|//)|(?==[^>])|(?<=[\}>\]\)]|[a-zA-Z_$])\s*(?=\{)
229229
patterns:
230230
- include: '#type'
231-
- include: '#comment'
232231

233232
type:
234233
name: meta.type.ts
235234
patterns:
236235
- include: '#type-primitive'
237236
- include: '#type-parameters'
238237
- include: '#type-tuple'
239-
- include: '#object-type'
238+
- include: '#type-object'
240239
- include: '#type-operator'
241-
- include: '#paren-type-or-function-type-parameters'
242-
- include: '#function-type-return-type'
240+
- include: '#type-paren-or-function-type-parameters'
241+
- include: '#type-function-return-type'
243242
- include: '#type-name'
244243

245244
function-type-parameters:
@@ -257,18 +256,20 @@ repository:
257256
- include: '#variable-initializer'
258257

259258
type-primitive:
260-
name: storage.type.ts
259+
name: meta.type.primitive.ts
261260
match: '\b(string|number|boolean|symbol|any|void)\b'
261+
captures:
262+
'1': { name: storage.type.ts }
262263

263264
# Parenthesis can contain either types and function parameters
264265
# (number | string) or (param: number, param2: string)
265266
# and it can be nested, for example
266267
# (number | (param: number, param2: string) => void)
267-
paren-type-or-function-type-parameters:
268+
type-paren-or-function-type-parameters:
268269
name: meta.type.paren.cover.ts
269270
begin: '(?:\b(new)\b)?\s*\('
270271
beginCaptures:
271-
'1': { name: keyword.operator.ts }
272+
'1': { name: keyword.control.ts }
272273
end: '\)'
273274
patterns:
274275
- include: '#comment'
@@ -279,12 +280,12 @@ repository:
279280
name: keyword.operator.type.ts
280281
match: '[.|]'
281282

282-
function-type-return-type:
283-
name: meta.function.type.return.ts
283+
type-function-return-type:
284+
name: meta.type.function.return.ts
284285
begin: '=>'
285286
beginCaptures:
286287
'0': { name: keyword.operator.ts }
287-
end: (?=[,\)\{=;]|//|$)
288+
end: (?=\s*[,\)\{=;]|//|$)
288289
patterns:
289290
- include: '#type'
290291

@@ -301,8 +302,10 @@ repository:
301302
- include: '#comment'
302303

303304
type-name:
304-
name: entity.name.type.ts
305+
name: meta.type.name.ts
305306
match: '[a-zA-Z_$][.\w$]*'
307+
captures:
308+
'1': { name: entity.name.type.ts }
306309

307310
type-parameters:
308311
name: meta.type.parameters.ts
@@ -329,6 +332,7 @@ repository:
329332
expression:
330333
name: meta.expression.ts
331334
patterns:
335+
- include: '#for-in-simple'
332336
- include: '#string'
333337
- include: '#regex'
334338
- include: '#template'
@@ -348,10 +352,10 @@ repository:
348352
- include: '#storage-keyword'
349353
- include: '#control-statement'
350354
- include: '#switch-case'
351-
- include: '#for-in-simple'
355+
352356
for-in-simple:
353357
name: forin.expr.ts
354-
match: (?<=\()\s*\b(var|let|const)\s+([a-zA-Z_$][\w$]*)\s+(in)\b
358+
match: (?<=\()\s*\b(var|let|const)\s+([a-zA-Z_$][\w$]*)\s+(in|of)\b
355359
captures:
356360
'1': { name: storage.type.ts }
357361
'3': { name: keyword.operator.ts }

0 commit comments

Comments
 (0)