aboutsummaryrefslogtreecommitdiffstats
path: root/queries/yuck/highlights.scm
blob: c885d909d72e7ca27e77bb9a0e4c8bd994ba3803 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
; 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)

; Includes

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

; 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
    (#any-of? @keyword "defwindow" "defwidget" "defvar" "defpoll" "deflisten" "geometry" "children" "struts")))

; Loop

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

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

; Builtin widgets

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

; Variables

(ident) @variable

(array
  (symbol) @variable)

; Properties & Fields

(keyword) @property

(json_access
  (_)
  "["
  (simplexpr
    (ident) @property))

(json_safe_access
  (_)
  "?."
  "["
  (simplexpr
    (ident) @property))

(json_dot_access
  (index) @property)

(json_safe_dot_access
  (index) @property)

(json_object
  (simplexpr
    (ident) @variable.member))

; Functions

(function_call
  name: (ident) @function.call)

; Operators

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

; Punctuation

[":" "." ","] @punctuation.delimiter
["{" "}" "[" "]" "(" ")"] @punctuation.bracket

; Ternary expression

(ternary_expression
  ["?" ":"] @keyword.conditional.ternary)

; Literals

(number) @number

(float) @number.float

(boolean) @boolean

; Strings

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

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

(escape_sequence) @string.escape

; Comments

(comment) @comment @spell