summaryrefslogtreecommitdiff
path: root/runtime/queries/yuck/highlights.scm
blob: 70de4cbe6801309f4352f70b0587f94e8faa08d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
; Errors

(ERROR) @error

; Comments

(comment) @comment

; Operators

[
  "+"
  "-"
  "*"
  "/"
  "%"
  "||"
  "&&"
  "=="
  "!="
  "=~"
  ">"
  "<"
  ">="
  "<="
  "!"
  "?."
  "?:"
] @operator

(ternary_expression
  ["?" ":"] @operator)

; Punctuation

[ ":" "." "," ] @punctuation.delimiter

[ "{" "}" "[" "]" "(" ")" ] @punctuation.bracket

; Literals

(number (float)) @constant.numeric.float

(number (integer)) @constant.numeric.integer

(boolean) @constant.builtin.boolean

; Strings

(escape_sequence) @constant.character.escape

(string_interpolation
  "${" @punctuation.special
  "}" @punctuation.special)

[ (string_fragment) "\"" "'" "`" ] @string

; Attributes & Fields

(keyword) @attribute

; Functions

(function_call
  name: (ident) @function)

; Variables

(ident) @variable

(array
  (symbol) @variable)

; Builtin widgets

(list .
  ((symbol) @tag.builtin
    (#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)$")))

; Keywords

; I think there's a bug in tree-sitter the anchor doesn't seem to be working, see
; https://github.com/tree-sitter/tree-sitter/pull/2107
(list .
  ((symbol) @keyword
    (#match? @keyword "^(defwindow|defwidget|defvar|defpoll|deflisten|geometry|children|struts)$")))

(list .
  ((symbol) @keyword.control.import
    (#eq? @keyword.control.import "include")))

; Loop

(loop_widget . "for" @keyword.control.repeat . (symbol) @variable . "in" @keyword.operator . (symbol) @variable)

(loop_widget . "for" @keyword.control.repeat . (symbol) @variable . "in" @keyword.operator)

; Tags

; TODO apply to every symbol in list? I think it should probably only be applied to the first child of the list
(list
  (symbol) @tag)

; Other stuff that has not been caught by the previous queries yet

(ident) @variable
(index) @variable