@@ -1,66 +1,107 @@
1+; Errors
2+
13(ERROR) @error
24
3−(line_comment) @comment
5+; Comments
46
5−; keywords and symbols
7+(comment) @comment
68
7−(keyword) @keyword
8−(symbol) @tag
9+; Operators
910
10−; literals
11+[
12+ "+"
13+ "-"
14+ "*"
15+ "/"
16+ "%"
17+ "||"
18+ "&&"
19+ "=="
20+ "!="
21+ "=~"
22+ ">"
23+ "<"
24+ ">="
25+ "<="
26+ "!"
27+ "?."
28+ "?:"
29+] @operator
1130
12−(bool_literal) @constant.builtin.boolean
13−(num_literal) @constant.numeric
31+(ternary_expression
32+ ["?" ":"] @operator)
1433
15−; strings
16−(string_interpolation
17− (string_interpolation_start) @punctuation.special
18− (string_interpolation_end) @punctuation.special)
34+; Punctuation
35+
36+[ ":" "." "," ] @punctuation.delimiter
37+
38+[ "{" "}" "[" "]" "(" ")" ] @punctuation.bracket
39+
40+; Literals
41+
42+(number (float)) @constant.numeric.float
43+
44+(number (integer)) @constant.numeric.integer
45+
46+(boolean) @constant.builtin.boolean
47+
48+; Strings
1949
2050(escape_sequence) @constant.character.escape
2151
22−(string
23− [
24− (unescaped_single_quote_string_fragment)
25− (unescaped_double_quote_string_fragment)
26− (unescaped_backtick_string_fragment)
27− "\""
28− "'"
29− "`"
30− ]) @string
52+(string_interpolation
53+ "${" @punctuation.special
54+ "}" @punctuation.special)
3155
32−; operators and general punctuation
56+[ (string_fragment) "\"" "'" "`" ] @string
3357
34−(unary_expression
35− operator: _ @operator)
58+; Attributes & Fields
3659
37−(binary_expression
38− operator: _ @operator)
60+(keyword) @attribute
3961
40−(ternary_expression
41− operator: _ @operator)
62+; Functions
4263
43−[
44− ":"
45− "."
46− ","
47−] @punctuation.delimiter
64+(function_call
65+ name: (ident) @function)
4866
49−[
50− "("
51− ")"
52− "["
53− "]"
54− "{"
55− "}"
56−] @punctuation.bracket
57−[
58− ":"
59− "."
60− ","
61−] @punctuation.delimiter
67+; Variables
6268
63−; Rest (general identifiers that are not yet catched)
69+(ident) @variable
70+
71+(array
72+ (symbol) @variable)
73+
74+; Builtin widgets
75+
76+(list .
77+ ((symbol) @tag.builtin
78+ (#match? @tag.builtin "^(box|button|calendar|centerbox|checkbox|circular-progress|color-button|color-chooser|combo-box-text|eventbox|expander|graph|image|input|label|literal|overlay|progress|revealer|scale|scroll|transform)$")))
79+
80+; Keywords
81+
82+; I think there's a bug in tree-sitter the anchor doesn't seem to be working, see
83+; https://github.com/tree-sitter/tree-sitter/pull/2107
84+(list .
85+ ((symbol) @keyword
86+ (#match? @keyword "^(defwindow|defwidget|defvar|defpoll|deflisten|geometry|children|struts)$")))
87+
88+(list .
89+ ((symbol) @keyword.control.import
90+ (#eq? @keyword.control.import "include")))
91+
92+; Loop
93+
94+(loop_widget . "for" @keyword.control.repeat . (symbol) @variable . "in" @keyword.operator . (symbol) @variable)
95+
96+(loop_widget . "for" @keyword.control.repeat . (symbol) @variable . "in" @keyword.operator)
97+
98+; Tags
99+
100+; TODO apply to every symbol in list? I think it should probably only be applied to the first child of the list
101+(list
102+ (symbol) @tag)
103+
104+; Other stuff that has not been catched by the previous queries yet
64105
65−(index) @variable
66106(ident) @variable
107+(index) @variable