@@ -8,6 +8,15 @@ scopeName: source.tsx
88fileTypes : [tsx]
99uuid : 805375ec-d614-41f5-8993-5843fe63ea82
1010
11+ variables :
12+ jsxTagOrAtrributeIdentifier : ' [_$a-zA-Z][-$\w.]'
13+ jsxTagNamespace : (?:({{jsxTagOrAtrributeIdentifier}}*)(?<!\.|-)(:))?
14+ jsxTagName : \s*{{jsxTagNamespace}}((?:[a-z][a-z0-9]*|({{jsxTagOrAtrributeIdentifier}}*))(?<!\.|-))
15+ jsxOpeningTagWithoutAttributes : (<){{jsxTagName}}?\s*(>)
16+ jsxClosingTag : (</){{jsxTagName}}?\s*(>)
17+ jsxTagStart : (<){{jsxTagName}}(?=\s+(?!\?)|\/?>)
18+ jsxTagStartLookahead : (?={{jsxTagStart}})
19+
1120repository :
1221 # Additions:
1322 # expression repository need to include jsx first followed by whaterver ts grammar says
@@ -34,15 +43,15 @@ repository:
3443 begin : |-
3544 (?x)
3645 (?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
37- (?=(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>) )
38- end : (?!\s*(<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>) )
46+ (?={{jsxOpeningTagWithoutAttributes}} )
47+ end : (?!\s*{{jsxOpeningTagWithoutAttributes}} )
3948 patterns :
4049 - include : ' #jsx-tag-without-attributes'
4150
4251 jsx-tag-without-attributes :
4352 name : meta.tag.without-attributes.tsx
44- begin : (<)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>)
45- end : (</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>)
53+ begin : ' {{jsxOpeningTagWithoutAttributes}} '
54+ end : ' {{jsxClosingTag}} '
4655 beginCaptures :
4756 ' 1 ' : {name: punctuation.definition.tag.begin.tsx}
4857 ' 2 ' : {name: entity.name.tag.namespace.tsx}
@@ -67,11 +76,8 @@ repository:
6776 (?x)
6877 (?<=[({\[,?=>:*]|&&|\|\||\?|{{lookBehindReturn}}|{{lookBehindDefault}}|^)\s*
6978 (?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
70- (?=(<)\s*
71- ([_$a-zA-Z][-$\w.]*(?<!\.|-):)?
72- ([_$a-zA-Z][-$\w.]*(?<!\.|-))
73- (?=\s+(?!\?)|/?>))
74- end : (/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))
79+ {{jsxTagStartLookahead}}
80+ end : (/>)|(?:{{jsxClosingTag}})
7581 endCaptures :
7682 ' 0 ' : { name: meta.tag.tsx }
7783 ' 1 ' : { name: punctuation.definition.tag.end.tsx }
@@ -86,13 +92,8 @@ repository:
8692
8793 jsx-child-tag :
8894 # Because this would be included from the jsx-children, this doesnt need to inspect surrounding context
89- begin : |-
90- (?x)
91- (?=(<)\s*
92- ([_$a-zA-Z][-$\w.]*(?<!\.|-):)?
93- ([_$a-zA-Z][-$\w.]*(?<!\.|-))
94- (?=\s+(?!\?)|/?>))
95- end : (/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))
95+ begin : ' {{jsxTagStartLookahead}}'
96+ end : (/>)|(?:{{jsxClosingTag}})
9697 endCaptures :
9798 ' 0 ' : { name: meta.tag.tsx }
9899 ' 1 ' : { name: punctuation.definition.tag.end.tsx }
@@ -107,20 +108,10 @@ repository:
107108
108109 jsx-tag :
109110 name : meta.tag.tsx
110- begin : |-
111- (?x)
112- (?=(<)\s*
113- (?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?
114- ([_$a-zA-Z][-$\w.]*(?<!\.|-))
115- (?=\s+(?!\?)|/?>))
116- end : (?=(/>)|(?:(</)\s*(?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)))
111+ begin : ' {{jsxTagStartLookahead}}'
112+ end : (?=(/>)|(?:{{jsxClosingTag}}))
117113 patterns :
118- - begin : |-
119- (?x)
120- (<)\s*
121- (?:([_$a-zA-Z][-$\w.]*)(?<!\.|-)(:))?
122- ((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))
123- (?=\s+(?!\?)|/?>)
114+ - begin : ' {{jsxTagStart}}'
124115 beginCaptures :
125116 ' 1 ' : { name: punctuation.definition.tag.begin.tsx }
126117 ' 2 ' : { name: entity.name.tag.namespace.tsx }
@@ -184,7 +175,7 @@ repository:
184175 match : |-
185176 (?x)
186177 \s*
187- (?:([_$a-zA-Z][-$\w.] *)(:))?
178+ (?:({{jsxTagOrAtrributeIdentifier}} *)(:))?
188179 ([_$a-zA-Z][-$\w]*)
189180 (?=\s|=|/?>|/\*|//)
190181 captures :
0 commit comments