1;;; ---
2;;; keywords
3[
4 "def"
5 "def-env"
6 "alias"
7 "export-env"
8 "export"
9 "extern"
10 "module"
11
12 "let"
13 "let-env"
14 "mut"
15 "const"
16
17 "hide-env"
18
19 "source"
20 "source-env"
21
22 "overlay"
23 "register"
24
25 "loop"
26 "while"
27 "error"
28
29 "do"
30 "if"
31 "else"
32 "try"
33 "catch"
34 "match"
35
36 "break"
37 "continue"
38 "return"
39
40] @keyword
41
42(hide_mod "hide" @keyword)
43(decl_use "use" @keyword)
44
45(ctrl_for
46 "for" @keyword
47 "in" @keyword
48)
49(overlay_list "list" @keyword)
50(overlay_hide "hide" @keyword)
51(overlay_new "new" @keyword)
52(overlay_use
53 "use" @keyword
54 "as" @keyword
55)
56(ctrl_error "make" @keyword)
57
58;;; ---
59;;; literals
60(val_number) @constant
61(val_duration
62 unit: [
63 "ns" "ยตs" "us" "ms" "sec" "min" "hr" "day" "wk"
64 ] @variable
65)
66(val_filesize
67 unit: [
68 "b" "B"
69
70 "kb" "kB" "Kb" "KB"
71 "mb" "mB" "Mb" "MB"
72 "gb" "gB" "Gb" "GB"
73 "tb" "tB" "Tb" "TB"
74 "pb" "pB" "Pb" "PB"
75 "eb" "eB" "Eb" "EB"
76 "zb" "zB" "Zb" "ZB"
77
78 "kib" "kiB" "kIB" "kIb" "Kib" "KIb" "KIB"
79 "mib" "miB" "mIB" "mIb" "Mib" "MIb" "MIB"
80 "gib" "giB" "gIB" "gIb" "Gib" "GIb" "GIB"
81 "tib" "tiB" "tIB" "tIb" "Tib" "TIb" "TIB"
82 "pib" "piB" "pIB" "pIb" "Pib" "PIb" "PIB"
83 "eib" "eiB" "eIB" "eIb" "Eib" "EIb" "EIB"
84 "zib" "ziB" "zIB" "zIb" "Zib" "ZIb" "ZIB"
85 ] @variable
86)
87(val_binary
88 [
89 "0b"
90 "0o"
91 "0x"
92 ] @constant
93 "[" @punctuation.bracket
94 digit: [
95 "," @punctuation.delimiter
96 (hex_digit) @constant
97 ]
98 "]" @punctuation.bracket
99) @constant
100(val_bool) @constant.builtin
101(val_nothing) @constant.builtin
102(val_string) @string
103(val_date) @constant
104(inter_escape_sequence) @constant
105(escape_sequence) @constant
106(val_interpolated [
107 "$\""
108 "$\'"
109 "\""
110 "\'"
111] @string)
112(unescaped_interpolated_content) @string
113(escaped_interpolated_content) @string
114(expr_interpolated ["(" ")"] @variable)
115
116;;; ---
117;;; operators
118(expr_binary [
119 "+"
120 "-"
121 "*"
122 "/"
123 "mod"
124 "//"
125 "++"
126 "**"
127 "=="
128 "!="
129 "<"
130 "<="
131 ">"
132 ">="
133 "=~"
134 "!~"
135 "and"
136 "or"
137 "xor"
138 "bit-or"
139 "bit-xor"
140 "bit-and"
141 "bit-shl"
142 "bit-shr"
143 "in"
144 "not-in"
145 "starts-with"
146 "ends-with"
147] @operator)
148
149(expr_binary opr: ([
150 "and"
151 "or"
152 "xor"
153 "bit-or"
154 "bit-xor"
155 "bit-and"
156 "bit-shl"
157 "bit-shr"
158 "in"
159 "not-in"
160 "starts-with"
161 "ends-with"
162]) @keyword)
163
164(where_command [
165 "+"
166 "-"
167 "*"
168 "/"
169 "mod"
170 "//"
171 "++"
172 "**"
173 "=="
174 "!="
175 "<"
176 "<="
177 ">"
178 ">="
179 "=~"
180 "!~"
181 "and"
182 "or"
183 "xor"
184 "bit-or"
185 "bit-xor"
186 "bit-and"
187 "bit-shl"
188 "bit-shr"
189 "in"
190 "not-in"
191 "starts-with"
192 "ends-with"
193] @operator)
194
195(assignment [
196 "="
197 "+="
198 "-="
199 "*="
200 "/="
201 "++="
202] @operator)
203
204(expr_unary ["not" "-"] @operator)
205
206(val_range [
207 ".."
208 "..="
209 "..<"
210] @operator)
211
212["=>" "=" "|"] @operator
213
214[
215 "o>" "out>"
216 "e>" "err>"
217 "e+o>" "err+out>"
218 "o+e>" "out+err>"
219] @special
220
221;;; ---
222;;; punctuation
223[
224 ","
225 ";"
226] @punctuation.delimiter
227
228(param_short_flag "-" @punctuation.delimiter)
229(param_long_flag ["--"] @punctuation.delimiter)
230(long_flag ["--"] @punctuation.delimiter)
231(param_rest "..." @punctuation.delimiter)
232(param_type [":"] @punctuation.special)
233(param_value ["="] @punctuation.special)
234(param_cmd ["@"] @punctuation.special)
235(param_opt ["?"] @punctuation.special)
236
237[
238 "(" ")"
239 "{" "}"
240 "[" "]"
241] @punctuation.bracket
242
243(val_record
244 (record_entry ":" @punctuation.delimiter))
245;;; ---
246;;; identifiers
247(param_rest
248 name: (_) @variable)
249(param_opt
250 name: (_) @variable)
251(parameter
252 param_name: (_) @variable)
253(param_cmd
254 (cmd_identifier) @string)
255(param_long_flag) @variable
256(param_short_flag) @variable
257
258(short_flag) @variable
259(long_flag) @variable
260
261(scope_pattern [(wild_card) @function])
262
263(cmd_identifier) @function
264
265(command
266 "^" @punctuation.delimiter
267 head: (_) @function
268)
269
270"where" @function
271
272(path
273 ["." "?"] @punctuation.delimiter
274) @variable
275
276(val_variable
277 "$" @operator
278 [
279 (identifier) @variable
280 "in" @type.builtin
281 "nu" @type.builtin
282 "env" @type.builtin
283 "nothing" @type.builtin
284 ] ; If we have a special styling, use it here
285)
286;;; ---
287;;; types
288(flat_type) @type.builtin
289(list_type
290 "list" @type
291 ["<" ">"] @punctuation.bracket
292)
293(collection_type
294 ["record" "table"] @type
295 "<" @punctuation.bracket
296 key: (_) @variable
297 ["," ":"] @punctuation.delimiter
298 ">" @punctuation.bracket
299)
300
301(shebang) @comment
302(comment) @comment