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