aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-04-01 08:18:44 +0000
committerBlaž Hrastnik2022-04-01 08:18:44 +0000
commit855e438f55cb278de8203ac4911561c4c7ad656c (patch)
tree7ff153d70807036b77584a88dddd33bcd09e34a6 /runtime/queries
parenta24fb17b2a978d3165bd6304e9edd69bddb6dd82 (diff)
jsx: Add special highlighting to component names
Diffstat (limited to 'runtime/queries')
-rw-r--r--runtime/queries/javascript/highlights.scm22
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/queries/javascript/highlights.scm b/runtime/queries/javascript/highlights.scm
index 96bad862..ccc58a9e 100644
--- a/runtime/queries/javascript/highlights.scm
+++ b/runtime/queries/javascript/highlights.scm
@@ -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)