Skip to content

Commit

Permalink
jsx: Add special highlighting to component names
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Apr 1, 2022
1 parent a24fb17 commit 855e438
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions runtime/queries/javascript/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
; JSX
;----

; Highlight component names differently

(jsx_opening_element ((identifier) @constructor
(#match? @constructor "^[A-Z]")))

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

(jsx_closing_element ((identifier) @constructor
(#match? @constructor "^[A-Z]")))

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

(jsx_self_closing_element ((identifier) @constructor
(#match? @constructor "^[A-Z]")))

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

; TODO: also tag @punctuation.delimiter?

(jsx_opening_element (identifier) @tag)
(jsx_closing_element (identifier) @tag)
(jsx_self_closing_element (identifier) @tag)
Expand Down

0 comments on commit 855e438

Please sign in to comment.