on master help sign in
fix: Improve JSX and TSX tag highlighting (#3973)
commit90468ad6c592c9a93e30b0809b42552e3b24f1e7 authorJacob Chandler <jchand1999@protonmail.com> dateMon 26 Sep 2022, 19:27 (4 years ago) parentd2bb7f5
2 files changed+14−4
runtime/queries/jsx/highlights.scm+13−3 runtime/queries/tsx/highlights.scm+1−1
runtime/queries/jsx/highlights.scm+13−3
@@ -1,5 +1,3 @@
1−; inherits: ecma
2−
31; Highlight component names differently
42(jsx_opening_element ((identifier) @constructor
53 (#match? @constructor "^[A-Z]")))
@@ -7,21 +5,33 @@
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
@@ -1 +1 @@
1−; inherits: typescript
1+; inherits: jsx,typescript