Skip to content

Commit 90468ad

Browse files
authored
fix: Improve JSX and TSX tag highlighting (#3973)
1 parent d2bb7f5 commit 90468ad

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

runtime/queries/jsx/highlights.scm

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
1-
; inherits: ecma
2-
31
; Highlight component names differently
42
(jsx_opening_element ((identifier) @constructor
53
(#match? @constructor "^[A-Z]")))
64

75
; Handle the dot operator effectively - <My.Component>
86
(jsx_opening_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
97

8+
; Highlight brackets differently
9+
(jsx_opening_element ["<" ">"] @punctuation.bracket)
10+
1011
(jsx_closing_element ((identifier) @constructor
1112
(#match? @constructor "^[A-Z]")))
1213

1314
; Handle the dot operator effectively - </My.Component>
1415
(jsx_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
1516

17+
; Highlight brackets differently
18+
(jsx_closing_element ["<" "/" ">"] @punctuation.bracket)
19+
1620
(jsx_self_closing_element ((identifier) @constructor
1721
(#match? @constructor "^[A-Z]")))
1822

1923
; Handle the dot operator effectively - <My.Component />
2024
(jsx_self_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
2125

22-
; TODO: also tag @punctuation.delimiter?
26+
; Highlight brackets differently
27+
(jsx_self_closing_element ["<" "/" ">"] @punctuation.bracket)
28+
29+
; Handle attribute delimiter
30+
(jsx_attribute "=" @punctuation.delimiter)
2331

2432
(jsx_opening_element (identifier) @tag)
2533
(jsx_closing_element (identifier) @tag)
2634
(jsx_self_closing_element (identifier) @tag)
2735
(jsx_attribute (property_identifier) @variable.other.member)
36+
37+
; inherits: ecma

runtime/queries/tsx/highlights.scm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
; inherits: typescript
1+
; inherits: jsx,typescript

0 commit comments

Comments
 (0)