Debian Codegraph @

runtime/queries/glimmer/highlights.scm

raw symbols SCIP
1 ; === Tag Names ===
2
3 ; Tags that start with a lower case letter are HTML tags
4 ; We'll also use this highlighting for named blocks (which start with `:`)
5 ((tag_name) @tag
6 (#match? @tag "^(:)?[a-z]"))
7 ; Tags that start with a capital letter are Glimmer components
8 ((tag_name) @constructor
9 (#match? @constructor "^[A-Z]"))
10
11 (attribute_name) @attribute
12
13 (string_literal) @string
14 (number_literal) @constant.numeric.integer
15 (boolean_literal) @constant.builtin.boolean
16
17 (concat_statement) @string
18
19 ; === Block Statements ===
20
21 ; Highlight the brackets
22 (block_statement_start) @punctuation.delimiter
23 (block_statement_end) @punctuation.delimiter
24
25 ; Highlight `if`/`each`/`let`
26 (block_statement_start path: (identifier) @keyword.control.conditional)
27 (block_statement_end path: (identifier) @keyword.control.conditional)
28 ((mustache_statement (identifier) @keyword.control.conditional)
29 (#eq? @keyword.control.conditional "else"))
30
31 ; == Mustache Statements ===
32
33 ; Highlight the whole statement, to color brackets and separators
34 (mustache_statement) @punctuation.delimiter
35
36 ; An identifier in a mustache expression is a variable
37 ((mustache_statement [
38 (path_expression (identifier) @variable)
39 (identifier) @variable
40 ])
41 (#not-any-of? @variable "yield" "outlet" "this" "else"))
42 ; As are arguments in a block statement
43 ((block_statement_start argument: [
44 (path_expression (identifier) @variable)
45 (identifier) @variable
46 ])
47 (#not-eq? @variable "this"))
48 ; As is an identifier in a block param
49 (block_params (identifier) @variable)
50 ; As are helper arguments
51 ((helper_invocation argument: [
52 (path_expression (identifier) @variable)
53 (identifier) @variable
54 ])
55 (#not-eq? @variable "this"))
56 ; `this` should be highlighted as a built-in variable
57 ((identifier) @variable.builtin
58 (#eq? @variable.builtin "this"))
59
60 ; If the identifier is just "yield" or "outlet", it's a keyword
61 ((mustache_statement (identifier) @keyword.control.return)
62 (#any-of? @keyword.control.return "yield" "outlet"))
63
64 ; Helpers are functions
65 ((helper_invocation helper: [
66 (path_expression (identifier) @function)
67 (identifier) @function
68 ])
69 (#not-any-of? @function "if" "yield"))
70
71 ((helper_invocation helper: (identifier) @keyword.control.conditional)
72 (#any-of? @keyword.control.conditional "if" "yield"))
73
74 (hash_pair key: (identifier) @variable)
75 (hash_pair value: (identifier) @variable)
76 (hash_pair [
77 (path_expression (identifier) @variable)
78 (identifier) @variable
79 ])
80
81 (comment_statement) @comment
82
83 (attribute_node "=" @operator)
84
85 (block_params "as" @keyword.control)
86 (block_params "|" @operator)
87
88 [
89 "<"
90 ">"
91 "</"
92 "/>"
93 ] @punctuation.delimiter
94