Skip to content

Commit

Permalink
refactor: use #any-of and #eq instead of #match
Browse files Browse the repository at this point in the history
  • Loading branch information
c0rydoras committed Mar 19, 2024
1 parent 802fc74 commit 88ebcf0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions runtime/queries/glimmer/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
(block_statement_start path: (identifier) @keyword.control.conditional)
(block_statement_end path: (identifier) @keyword.control.conditional)
((mustache_statement (identifier) @keyword.control.conditional)
(#match? @keyword.control.conditional "else"))
(#eq? @keyword.control.conditional "else"))

; == Mustache Statements ===

Expand All @@ -38,39 +38,38 @@
(path_expression (identifier) @variable)
(identifier) @variable
])
(#not-match? @variable "yield|outlet|this|else"))
(#not-any-of? @variable "yield" "outlet" "this" "else"))
; As are arguments in a block statement
((block_statement_start argument: [
(path_expression (identifier) @variable)
(identifier) @variable
])
(#not-match? @variable "this"))
(#not-eq? @variable "this"))
; As is an identifier in a block param
(block_params (identifier) @variable)
; As are helper arguments
((helper_invocation argument: [
(path_expression (identifier) @variable)
(identifier) @variable
])
(#not-match? @variable "this"))
(#not-eq? @variable "this"))
; `this` should be highlighted as a built-in variable
((identifier) @variable.builtin
(#match? @variable.builtin "this"))
(#eq? @variable.builtin "this"))

; If the identifier is just "yield" or "outlet", it's a keyword
((mustache_statement (identifier) @keyword.control.return)
(#match? @keyword.control.return "yield|outlet"))
(#any-of? @keyword.control.return "yield" "outlet"))

; Helpers are functions
((helper_invocation helper: [
(path_expression (identifier) @function)
(identifier) @function
])
(#not-match? @function "if|yield"))
((helper_invocation helper: (identifier) @keyword.control.conditional)
(#match? @keyword.control.conditional "if"))
(#not-any-of? @function "if" "yield"))

((helper_invocation helper: (identifier) @keyword.control.conditional)
(#match? @keyword.control.conditional "yield"))
(#any-of? @keyword.control.conditional "if" "yield"))

(hash_pair key: (identifier) @variable)
(hash_pair value: (identifier) @variable)
Expand All @@ -92,3 +91,4 @@
"</"
"/>"
] @punctuation.delimiter

0 comments on commit 88ebcf0

Please sign in to comment.