aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/roc/highlights.scm
blob: 4993017dce535257b1318792f81a9b3a16aa0721 (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
;---Most generic types---
(module) @module

(identifier) @variable

(concrete_type) @type

;---annotations----
(annotation_type_def
  (annotation_pre_colon
    (identifier) @type))

(annotation_type_def
  (annotation_pre_colon
    (identifier) @function)
  (function_type))

;----decleration types----
(value_declaration
  (decl_left
    (identifier_pattern
      (identifier) @variable.parameter)))

;---records----
(field_name) @variable.member

(record_field_pattern
  (_
    (identifier) @variable))

;matches the second identifier and all subsequent ones
(field_access_expr
  (identifier) @variable.member)

;highlight module members as records instead of free variables
; avoids highlighting them as out-of-scope vars
(variable_expr
  (module)
  (identifier) @variable.member)

;----comments----
(line_comment) @comment @spell

(doc_comment) @comment.documentation @spell

;-----Punctuation----
[
  "?"
  (arrow)
  (fat_arrow)
  "|"
  ","
  ":"
] @punctuation.delimiter

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

[
  "|"
  "&"
  "<-"
  ".."
  (operator)
] @operator

(wildcard_pattern) @character.special

[
  "if"
  "then"
  "else"
] @keyword.conditional

[
  (implements)
  (when)
  (is)
  (as)
  "as"
  (to)
] @keyword

;----headers-----
[
  "app"
  "expect"
  "module"
  "package"
] @keyword

"import" @keyword.import

(value_declaration
  (decl_left
    (identifier_pattern
      (identifier) @function))
  (expr_body
    (anon_fun_expr)))

;----tags----
(tags_type
  (tag_type) @constructor)

[
  (tag)
  (opaque_tag)
] @constructor

;-----builtins----
(variable_expr
  (module) @module
  (identifier) @boolean
  (#any-of? @boolean "true" "false")
  (#eq? @module "Bool"))

"dbg" @keyword.debug

;----function invocations ----
(function_call_pnc_expr
  caller: (variable_expr
    (identifier) @function.call))

(function_call_pnc_expr
  caller: (field_access_expr
    (identifier) @function.call .))

(bin_op_expr
  (operator
    "|>") @operator
  (variable_expr
    (identifier) @function))

;----function arguments----
(argument_patterns
  (identifier_pattern
    (identifier) @variable.parameter))

(argument_patterns
  (_
    (identifier_pattern
      (identifier) @variable.parameter)))

(argument_patterns
  (_
    (_
      (identifier_pattern
        (identifier) @variable.parameter))))

;-----consts-----
[
  (int)
  (uint)
  (iint)
  (xint)
  (natural)
] @number

[
  (decimal)
  (float)
] @number.float

[
  (string)
  (multiline_string)
] @string

(char) @character