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