@@ -52,6 +52,7 @@ variables:
52
52
matchingBraces : (\{([^\{\}]|(\{[^\{\}]*\}))*\})
53
53
matchingBrackets : (\[([^\[\]]|(\[[^\[\]]*\]))*\])
54
54
inlineComment : \/\*([^\*]|(\*[^\/]))*\*\/
55
+ startOfDeclaration : ' {{startOfIdentifier}}(?:(\bexport)\s+)?(?:(\bdeclare)\s+)?'
55
56
lookBehindOfPossiblyMultilineArrowWithDestructuring : (?<=[(=,])
56
57
lookBehindOfPossiblyMultilineArrow : (?<=[(=,]|=>)
57
58
lookBehindOfObjectMemberPossiblyMultilineArrow : (?<=:)
@@ -144,17 +145,19 @@ repository:
144
145
145
146
declaration :
146
147
patterns :
147
- - include : ' #decorator'
148
- - include : ' #var-expr'
149
- - include : ' #function-declaration'
150
- - include : ' #class-declaration'
151
- - include : ' #interface-declaration'
152
- - include : ' #enum-declaration'
153
- - include : ' #namespace-declaration'
154
- - include : ' #type-alias-declaration'
155
- - include : ' #import-equals-declaration'
156
- - include : ' #import-declaration'
157
- - include : ' #export-declaration'
148
+ - include : ' #decorator'
149
+ - include : ' #var-expr'
150
+ - include : ' #function-declaration'
151
+ - include : ' #class-declaration'
152
+ - include : ' #interface-declaration'
153
+ - include : ' #enum-declaration'
154
+ - include : ' #namespace-declaration'
155
+ - include : ' #type-alias-declaration'
156
+ - include : ' #import-equals-declaration'
157
+ - include : ' #import-declaration'
158
+ - include : ' #export-declaration'
159
+ - name : storage.modifier.ts
160
+ match : ' {{startOfIdentifier}}(declare){{endOfIdentifier}}'
158
161
159
162
control-statement :
160
163
patterns :
@@ -180,8 +183,6 @@ repository:
180
183
match : ' {{startOfIdentifier}}(package){{endOfIdentifier}}'
181
184
- name : keyword.other.debugger.ts
182
185
match : ' {{startOfIdentifier}}(debugger){{endOfIdentifier}}'
183
- - name : storage.modifier.ts
184
- match : ' {{startOfIdentifier}}(declare){{endOfIdentifier}}'
185
186
186
187
label :
187
188
patterns :
@@ -244,10 +245,11 @@ repository:
244
245
patterns :
245
246
# let/var
246
247
- name : meta.var.expr.ts
247
- begin : ' {{startOfIdentifier}}(?:(\bexport)\s+)? \b(var|let){{endOfIdentifier}}'
248
+ begin : ' {{startOfDeclaration}} \b(var|let){{endOfIdentifier}}'
248
249
beginCaptures :
249
250
' 1 ' : { name: keyword.control.export.ts }
250
- ' 2 ' : { name: storage.type.ts }
251
+ ' 2 ' : { name: storage.modifier.ts }
252
+ ' 3 ' : { name: storage.type.ts }
251
253
end : ((?=;|}|(\s+(of|in)\s+)|^\s*$|{{endOfStatement}})|((?<=\S)(?<!{{lookBehindLet}}|{{lookBehindVar}})(?=\s*$)))
252
254
patterns :
253
255
- include : ' #destructuring-variable'
@@ -266,10 +268,11 @@ repository:
266
268
- include : ' #punctuation-comma'
267
269
# const
268
270
- name : meta.var.expr.ts
269
- begin : ' {{startOfIdentifier}}(?:(\bexport)\s+)? \b(const(?!\s+enum\b)){{endOfIdentifier}}'
271
+ begin : ' {{startOfDeclaration}} \b(const(?!\s+enum\b)){{endOfIdentifier}}'
270
272
beginCaptures :
271
273
' 1 ' : { name: keyword.control.export.ts }
272
- ' 2 ' : { name: storage.type.ts }
274
+ ' 2 ' : { name: storage.modifier.ts }
275
+ ' 3 ' : { name: storage.type.ts }
273
276
end : ((?=;|}|(\s+(of|in)\s+)|^\s*$|{{endOfStatement}})|((?<=\S)(?<!{{lookBehindConst}})(?=\s*$)))
274
277
patterns :
275
278
- include : ' #destructuring-const'
@@ -629,13 +632,14 @@ repository:
629
632
# functions, methods, function expressions, arrows, indexers
630
633
function-declaration :
631
634
name : meta.function.ts
632
- begin : ' {{startOfIdentifier}}(?:(export)\s+)? (?:(async)\s+)?(function\b)(?:\s*(\*))?(?:(?:\s+|(?<=\*))({{identifier}}))?\s*'
635
+ begin : ' {{startOfDeclaration}} (?:(async)\s+)?(function\b)(?:\s*(\*))?(?:(?:\s+|(?<=\*))({{identifier}}))?\s*'
633
636
beginCaptures :
634
637
' 1 ' : { name: keyword.control.export.ts }
635
- ' 2 ' : { name: storage.modifier.async.ts }
636
- ' 3 ' : { name: storage.type.function.ts }
637
- ' 4 ' : { name: keyword.generator.asterisk.ts }
638
- ' 5 ' : { name: meta.definition.function.ts entity.name.function.ts }
638
+ ' 2 ' : { name: storage.modifier.ts }
639
+ ' 3 ' : { name: storage.modifier.async.ts }
640
+ ' 4 ' : { name: storage.type.function.ts }
641
+ ' 5 ' : { name: keyword.generator.asterisk.ts }
642
+ ' 6 ' : { name: meta.definition.function.ts entity.name.function.ts }
639
643
end : (?=$|^|;)|(?<=\})
640
644
patterns :
641
645
- include : ' #function-name'
@@ -836,11 +840,12 @@ repository:
836
840
# class declaration and expression, interface
837
841
class-declaration :
838
842
name : meta.class.ts
839
- begin : ' {{startOfIdentifier}}(?:(export)\s+)? \b(?:(abstract)\s+)?\b(class)\b(?=\s+|/[/*])'
843
+ begin : ' {{startOfDeclaration}} \b(?:(abstract)\s+)?\b(class)\b(?=\s+|/[/*])'
840
844
beginCaptures :
841
845
' 1 ' : { name: keyword.control.export.ts }
842
846
' 2 ' : { name: storage.modifier.ts }
843
- ' 3 ' : { name: storage.type.class.ts }
847
+ ' 3 ' : { name: storage.modifier.ts }
848
+ ' 4 ' : { name: storage.type.class.ts }
844
849
end : (?<=\})
845
850
patterns :
846
851
- include : ' #class-declaration-or-expression-patterns'
@@ -867,11 +872,12 @@ repository:
867
872
868
873
interface-declaration :
869
874
name : meta.interface.ts
870
- begin : ' {{startOfIdentifier}}(?:(export)\s+)? \b(?:(abstract)\s+)?\b(interface)\b(?=\s+|/[/*])'
875
+ begin : ' {{startOfDeclaration}} \b(?:(abstract)\s+)?\b(interface)\b(?=\s+|/[/*])'
871
876
beginCaptures :
872
877
' 1 ' : { name: keyword.control.export.ts }
873
878
' 2 ' : { name: storage.modifier.ts }
874
- ' 3 ' : { name: storage.type.interface.ts }
879
+ ' 3 ' : { name: storage.modifier.ts }
880
+ ' 4 ' : { name: storage.type.interface.ts }
875
881
end : (?<=\})
876
882
patterns :
877
883
- include : ' #comment'
@@ -945,12 +951,13 @@ repository:
945
951
# enum
946
952
enum-declaration :
947
953
name : meta.enum.declaration.ts
948
- begin : ' {{startOfIdentifier}}(?:(\bexport)\s+)? (?:\b(const)\s+)?\b(enum)\s+({{identifier}})'
954
+ begin : ' {{startOfDeclaration}} (?:\b(const)\s+)?\b(enum)\s+({{identifier}})'
949
955
beginCaptures :
950
956
' 1 ' : { name: keyword.control.export.ts }
951
957
' 2 ' : { name: storage.modifier.ts}
952
- ' 3 ' : { name: storage.type.enum.ts }
953
- ' 4 ' : { name: entity.name.type.enum.ts }
958
+ ' 3 ' : { name: storage.modifier.ts}
959
+ ' 4 ' : { name: storage.type.enum.ts }
960
+ ' 5 ' : { name: entity.name.type.enum.ts }
954
961
end : (?<=\})
955
962
patterns :
956
963
- include : ' #comment'
@@ -981,10 +988,11 @@ repository:
981
988
# namespace
982
989
namespace-declaration :
983
990
name : meta.namespace.declaration.ts
984
- begin : (?:{{startOfIdentifier}}(?:(\bexport)\s+)? \b(namespace|module)\s+(?=[_$[:alpha:]"'`]))
991
+ begin : (?:{{startOfDeclaration}} \b(namespace|module)\s+(?=[_$[:alpha:]"'`]))
985
992
beginCaptures :
986
993
' 1 ' : { name: keyword.control.export.ts }
987
- ' 2 ' : { name: storage.type.namespace.ts }
994
+ ' 2 ' : { name: storage.modifier.ts }
995
+ ' 3 ' : { name: storage.type.namespace.ts }
988
996
end : (?<=\})|(?={{endOfStatement}})
989
997
patterns :
990
998
- include : ' #comment'
@@ -997,11 +1005,12 @@ repository:
997
1005
# type alias
998
1006
type-alias-declaration :
999
1007
name : meta.type.declaration.ts
1000
- begin : ' {{startOfIdentifier}}(?:(\bexport)\s+)? \b(type)\b\s+({{identifier}})\s*'
1008
+ begin : ' {{startOfDeclaration}} \b(type)\b\s+({{identifier}})\s*'
1001
1009
beginCaptures :
1002
1010
' 1 ' : { name: keyword.control.export.ts }
1003
- ' 2 ' : { name: storage.type.type.ts }
1004
- ' 3 ' : { name: entity.name.type.alias.ts }
1011
+ ' 2 ' : { name: storage.modifier.ts }
1012
+ ' 3 ' : { name: storage.type.type.ts }
1013
+ ' 4 ' : { name: entity.name.type.alias.ts }
1005
1014
end : (?=\}|{{endOfStatement}})
1006
1015
patterns :
1007
1016
- include : ' #comment'
@@ -1017,27 +1026,29 @@ repository:
1017
1026
import-equals-declaration :
1018
1027
patterns :
1019
1028
- name : meta.import-equals.external.ts
1020
- begin : ' {{startOfIdentifier}}(?:(\bexport)\s+)? \b(import)\s+({{identifier}})\s*(=)\s*(require)\s*(\()'
1029
+ begin : ' {{startOfDeclaration}} \b(import)\s+({{identifier}})\s*(=)\s*(require)\s*(\()'
1021
1030
beginCaptures :
1022
1031
' 1 ' : { name: keyword.control.export.ts }
1023
- ' 2 ' : { name: keyword.control.import.ts }
1024
- ' 3 ' : { name: variable.other.readwrite.alias.ts }
1025
- ' 4 ' : { name: keyword.operator.assignment.ts }
1026
- ' 5 ' : { name: keyword.control.require.ts }
1027
- ' 6 ' : { name: meta.brace.round.ts }
1032
+ ' 2 ' : { name: storage.modifier.ts }
1033
+ ' 3 ' : { name: keyword.control.import.ts }
1034
+ ' 4 ' : { name: variable.other.readwrite.alias.ts }
1035
+ ' 5 ' : { name: keyword.operator.assignment.ts }
1036
+ ' 6 ' : { name: keyword.control.require.ts }
1037
+ ' 7 ' : { name: meta.brace.round.ts }
1028
1038
end : \)
1029
1039
endCaptures :
1030
1040
' 0 ' : { name: meta.brace.round.ts }
1031
1041
patterns :
1032
1042
- include : ' #comment'
1033
1043
- include : ' #string'
1034
1044
- name : meta.import-equals.internal.ts
1035
- begin : ' {{startOfIdentifier}}(?:(\bexport)\s+)? \b(import)\s+({{identifier}})\s*(=)\s*(?!require\b)'
1045
+ begin : ' {{startOfDeclaration}} \b(import)\s+({{identifier}})\s*(=)\s*(?!require\b)'
1036
1046
beginCaptures :
1037
1047
' 1 ' : { name: keyword.control.export.ts }
1038
- ' 2 ' : { name: keyword.control.import.ts }
1039
- ' 3 ' : { name: variable.other.readwrite.alias.ts }
1040
- ' 4 ' : { name: keyword.operator.assignment.ts }
1048
+ ' 2 ' : { name: storage.modifier.ts }
1049
+ ' 3 ' : { name: keyword.control.import.ts }
1050
+ ' 4 ' : { name: variable.other.readwrite.alias.ts }
1051
+ ' 5 ' : { name: keyword.operator.assignment.ts }
1041
1052
end : (?=;|$|^)
1042
1053
patterns :
1043
1054
- include : ' #comment'
@@ -1051,10 +1062,11 @@ repository:
1051
1062
1052
1063
import-declaration :
1053
1064
name : meta.import.ts
1054
- begin : ' {{startOfIdentifier}}(?:(\bexport)\s+)? \b(import)(?!\s*[:\(]){{endOfIdentifier}}'
1065
+ begin : ' {{startOfDeclaration}} \b(import)(?!\s*[:\(]){{endOfIdentifier}}'
1055
1066
beginCaptures :
1056
1067
' 1 ' : { name: keyword.control.export.ts }
1057
- ' 2 ' : { name: keyword.control.import.ts }
1068
+ ' 2 ' : { name: storage.modifier.ts }
1069
+ ' 3 ' : { name: keyword.control.import.ts }
1058
1070
end : (?<!{{lookBehindImport}})(?=;|$|^)
1059
1071
patterns :
1060
1072
- include : ' #comment'
0 commit comments