| 1 |
|
| 2 |
|
| 3 |
[ |
| 4 |
"let" |
| 5 |
"mut" |
| 6 |
"const" |
| 7 |
] @keyword |
| 8 |
|
| 9 |
[ |
| 10 |
"if" |
| 11 |
"else" |
| 12 |
"match" |
| 13 |
] @keyword.control.conditional |
| 14 |
|
| 15 |
[ |
| 16 |
"loop" |
| 17 |
"while" |
| 18 |
] @keyword.control.repeat |
| 19 |
|
| 20 |
"def" @keyword.function |
| 21 |
|
| 22 |
[ |
| 23 |
"try" |
| 24 |
"catch" |
| 25 |
"error" |
| 26 |
] @keyword.control.exception |
| 27 |
|
| 28 |
[ |
| 29 |
"module" |
| 30 |
"use" |
| 31 |
] @keyword.control.import |
| 32 |
|
| 33 |
[ |
| 34 |
"alias" |
| 35 |
"export-env" |
| 36 |
"export" |
| 37 |
"extern" |
| 38 |
] @keyword.storage.modifier |
| 39 |
|
| 40 |
(decl_use |
| 41 |
"use" @keyword.control.import) |
| 42 |
|
| 43 |
(ctrl_for |
| 44 |
"for" @keyword.control.repeat |
| 45 |
"in" @keyword.control.repeat) |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
(val_number) @constant.numeric |
| 50 |
|
| 51 |
(val_duration |
| 52 |
unit: _ @variable.parameter) |
| 53 |
|
| 54 |
(val_filesize |
| 55 |
unit: _ @variable.parameter) |
| 56 |
|
| 57 |
(val_binary |
| 58 |
[ |
| 59 |
"0b" |
| 60 |
"0o" |
| 61 |
"0x" |
| 62 |
] @constant.numeric |
| 63 |
"[" @punctuation.bracket |
| 64 |
digit: [ |
| 65 |
"," @punctuation.delimiter |
| 66 |
(hex_digit) @constant.numeric |
| 67 |
] |
| 68 |
"]" @punctuation.bracket) @constant.numeric |
| 69 |
|
| 70 |
(val_bool) @constant.builtin.boolean |
| 71 |
|
| 72 |
(val_nothing) @constant.builtin |
| 73 |
|
| 74 |
(val_string) @string |
| 75 |
|
| 76 |
arg_str: (val_string) @variable.parameter |
| 77 |
|
| 78 |
file_path: (val_string) @variable.parameter |
| 79 |
|
| 80 |
(val_date) @constant.numeric |
| 81 |
|
| 82 |
(inter_escape_sequence) @constant.character.escape |
| 83 |
|
| 84 |
(escape_sequence) @constant.character.escape |
| 85 |
|
| 86 |
(val_interpolated |
| 87 |
[ |
| 88 |
"$\"" |
| 89 |
"$\'" |
| 90 |
"\"" |
| 91 |
"\'" |
| 92 |
] @string) |
| 93 |
|
| 94 |
(unescaped_interpolated_content) @string |
| 95 |
|
| 96 |
(escaped_interpolated_content) @string |
| 97 |
|
| 98 |
(expr_interpolated |
| 99 |
[ |
| 100 |
"(" |
| 101 |
")" |
| 102 |
] @variable.parameter) |
| 103 |
|
| 104 |
(raw_string_begin) @punctuation.special |
| 105 |
|
| 106 |
(raw_string_end) @punctuation.special |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
(expr_binary |
| 111 |
opr: _ @operator) |
| 112 |
|
| 113 |
(where_predicate |
| 114 |
opr: _ @operator) |
| 115 |
|
| 116 |
(assignment |
| 117 |
[ |
| 118 |
"=" |
| 119 |
"+=" |
| 120 |
"-=" |
| 121 |
"*=" |
| 122 |
"/=" |
| 123 |
"++=" |
| 124 |
] @operator) |
| 125 |
|
| 126 |
(expr_unary |
| 127 |
[ |
| 128 |
"not" |
| 129 |
"-" |
| 130 |
] @operator) |
| 131 |
|
| 132 |
(val_range |
| 133 |
[ |
| 134 |
".." |
| 135 |
"..=" |
| 136 |
"..<" |
| 137 |
] @operator) |
| 138 |
|
| 139 |
[ |
| 140 |
"=>" |
| 141 |
"=" |
| 142 |
"|" |
| 143 |
] @operator |
| 144 |
|
| 145 |
[ |
| 146 |
"o>" |
| 147 |
"out>" |
| 148 |
"e>" |
| 149 |
"err>" |
| 150 |
"e+o>" |
| 151 |
"err+out>" |
| 152 |
"o+e>" |
| 153 |
"out+err>" |
| 154 |
"o>>" |
| 155 |
"out>>" |
| 156 |
"e>>" |
| 157 |
"err>>" |
| 158 |
"e+o>>" |
| 159 |
"err+out>>" |
| 160 |
"o+e>>" |
| 161 |
"out+err>>" |
| 162 |
"e>|" |
| 163 |
"err>|" |
| 164 |
"e+o>|" |
| 165 |
"err+out>|" |
| 166 |
"o+e>|" |
| 167 |
"out+err>|" |
| 168 |
] @operator |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
[ |
| 173 |
"," |
| 174 |
";" |
| 175 |
] @punctuation.special |
| 176 |
|
| 177 |
(param_long_flag |
| 178 |
"--" @punctuation.delimiter) |
| 179 |
|
| 180 |
(long_flag |
| 181 |
"--" @punctuation.delimiter) |
| 182 |
|
| 183 |
(short_flag |
| 184 |
"-" @punctuation.delimiter) |
| 185 |
|
| 186 |
(long_flag |
| 187 |
"=" @punctuation.special) |
| 188 |
|
| 189 |
(short_flag |
| 190 |
"=" @punctuation.special) |
| 191 |
|
| 192 |
(param_short_flag |
| 193 |
"-" @punctuation.delimiter) |
| 194 |
|
| 195 |
(param_rest |
| 196 |
"..." @punctuation.delimiter) |
| 197 |
|
| 198 |
(param_type |
| 199 |
":" @punctuation.special) |
| 200 |
|
| 201 |
(param_value |
| 202 |
"=" @punctuation.special) |
| 203 |
|
| 204 |
(param_cmd |
| 205 |
"@" @punctuation.special) |
| 206 |
|
| 207 |
(attribute |
| 208 |
"@" @punctuation.special) |
| 209 |
|
| 210 |
(param_opt |
| 211 |
"?" @punctuation.special) |
| 212 |
|
| 213 |
(returns |
| 214 |
"->" @punctuation.special) |
| 215 |
|
| 216 |
[ |
| 217 |
"(" |
| 218 |
")" |
| 219 |
"{" |
| 220 |
"}" |
| 221 |
"[" |
| 222 |
"]" |
| 223 |
"...[" |
| 224 |
"...(" |
| 225 |
"...{" |
| 226 |
] @punctuation.bracket |
| 227 |
|
| 228 |
(val_record |
| 229 |
(record_entry |
| 230 |
":" @punctuation.delimiter)) |
| 231 |
|
| 232 |
key: (identifier) @property |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
(param_rest |
| 237 |
name: (_) @variable.parameter) |
| 238 |
|
| 239 |
(param_opt |
| 240 |
name: (_) @variable.parameter) |
| 241 |
|
| 242 |
(parameter |
| 243 |
param_name: (_) @variable.parameter) |
| 244 |
|
| 245 |
(param_cmd |
| 246 |
(cmd_identifier) @string) |
| 247 |
|
| 248 |
(param_long_flag |
| 249 |
(long_flag_identifier) @attribute) |
| 250 |
|
| 251 |
(param_short_flag |
| 252 |
(param_short_flag_identifier) @attribute) |
| 253 |
|
| 254 |
(attribute |
| 255 |
(attribute_identifier) @attribute) |
| 256 |
|
| 257 |
(short_flag |
| 258 |
(short_flag_identifier) @attribute) |
| 259 |
|
| 260 |
(long_flag_identifier) @attribute |
| 261 |
|
| 262 |
(scope_pattern |
| 263 |
(wild_card) @function) |
| 264 |
|
| 265 |
(cmd_identifier) @function |
| 266 |
|
| 267 |
(decl_def . "def" |
| 268 |
(val_string |
| 269 |
(string_content) @function |
| 270 |
) |
| 271 |
) |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
(command |
| 280 |
head: (cmd_identifier) @function.builtin |
| 281 |
(#any-of? @function.builtin |
| 282 |
"all" "ansi" "any" "append" "ast" "bits" "bytes" "cal" "cd" "char" "chunk-by" "chunks" "clear" "collect" "columns" "compact" "complete" "config" "cp" "date" "debug" "decode" "default" "detect" "drop" "du" "each" "encode" "enumerate" "every" "exec" "exit" "explain" "explore" "fill" "filter" "find" "first" "flatten" "format" "from" "generate" "get" "glob" "grid" "group-by" "hash" "headers" "histogram" "history" "http" "input" "insert" "inspect" "interleave" "into" "is-empty" "is-not-empty" "is-terminal" "items" "job" "join" "keybindings" "kill" "last" "length" "let-env" "lines" "load-env" "ls" "math" "merge" "metadata" "mkdir" "mktemp" "move" "mv" "nu-check" "nu-highlight" "open" "panic" "par-each" "parse" "path" "plugin" "port" "prepend" "print" "ps" "query" "random" "reduce" "reject" "rename" "reverse" "rm" "roll" "rotate" "run-external" "save" "schema" "select" "seq" "shuffle" "skip" "sleep" "slice" "sort" "sort-by" "split" "start" "stor" "str" "sys" "table" "take" "tee" "term" "timeit" "to" "touch" "transpose" "tutor" "ulimit" "uname" "uniq" "uniq-by" "update" "upsert" "url" "values" "version" "view" "watch" "which" "whoami" "window" "with-env" "wrap" "zip")) |
| 283 |
|
| 284 |
(command |
| 285 |
head: (cmd_identifier) @keyword.control.repeat |
| 286 |
(#any-of? @keyword.control.repeat "break" "continue" "return")) |
| 287 |
|
| 288 |
(command |
| 289 |
head: (cmd_identifier) @keyword |
| 290 |
(#any-of? @keyword "do" "source" "source-env" "hide" "hide-env")) |
| 291 |
|
| 292 |
(command |
| 293 |
head: (cmd_identifier) @keyword |
| 294 |
. |
| 295 |
arg_str: (val_string) @keyword.control.import |
| 296 |
(#any-of? @keyword "overlay" "error")) |
| 297 |
|
| 298 |
(command |
| 299 |
head: (cmd_identifier) @cmd |
| 300 |
arg_str: (val_string) @keyword |
| 301 |
(#eq? @cmd "overlay") |
| 302 |
(#eq? @keyword "as")) |
| 303 |
|
| 304 |
(command |
| 305 |
"^" @punctuation.delimiter |
| 306 |
head: (_) @function) |
| 307 |
|
| 308 |
"where" @function.builtin |
| 309 |
|
| 310 |
(where_predicate |
| 311 |
[ |
| 312 |
"?" |
| 313 |
"!" |
| 314 |
] @punctuation.delimiter) |
| 315 |
|
| 316 |
(path |
| 317 |
[ |
| 318 |
"." |
| 319 |
"?" |
| 320 |
"!" |
| 321 |
]? @punctuation.delimiter) @variable.parameter |
| 322 |
|
| 323 |
(stmt_let |
| 324 |
(identifier) @variable) |
| 325 |
|
| 326 |
(val_variable |
| 327 |
"$"? @punctuation.special |
| 328 |
"...$"? @punctuation.special |
| 329 |
[ |
| 330 |
(identifier) @variable |
| 331 |
"in" @special |
| 332 |
"nu" @namespace |
| 333 |
"env" @constant |
| 334 |
]) @none |
| 335 |
|
| 336 |
(val_cellpath |
| 337 |
"$" @punctuation.special) |
| 338 |
|
| 339 |
(record_entry |
| 340 |
":" @punctuation.special) |
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
(flat_type) @type |
| 345 |
|
| 346 |
(list_type |
| 347 |
"list" @type.enum |
| 348 |
[ |
| 349 |
"<" |
| 350 |
">" |
| 351 |
] @punctuation.bracket) |
| 352 |
|
| 353 |
(collection_type |
| 354 |
[ |
| 355 |
"record" |
| 356 |
"table" |
| 357 |
] @type.enum |
| 358 |
"<" @punctuation.bracket |
| 359 |
key: (_) @variable.parameter |
| 360 |
[ |
| 361 |
"," |
| 362 |
":" |
| 363 |
] @punctuation.special |
| 364 |
">" @punctuation.bracket) |
| 365 |
|
| 366 |
(composite_type |
| 367 |
"oneof" @type.enum |
| 368 |
[ |
| 369 |
"<" |
| 370 |
">" |
| 371 |
] @punctuation.bracket) |
| 372 |
|
| 373 |
[(comment) (shebang)] @comment |
| 374 |
|
| 375 |
((comment)+ @comment.line.documentation |
| 376 |
. |
| 377 |
(decl_def)) |
| 378 |
|
| 379 |
(parameter |
| 380 |
(comment) @comment.line.documentation) |
| 381 |
|
| 382 |
(command |
| 383 |
head: ((cmd_identifier) @function.builtin |
| 384 |
(#match? @function.builtin "^\\s*(find|parse|split|str)$")) |
| 385 |
flag: (_ |
| 386 |
name: (_) @attribute |
| 387 |
(#any-of? @attribute "r" "regex")) |
| 388 |
. |
| 389 |
arg: (_ |
| 390 |
(string_content) @string.regexp)) |
| 391 |
|
| 392 |
(_ |
| 393 |
opr: [ |
| 394 |
"=~" |
| 395 |
"!~" |
| 396 |
"like" |
| 397 |
"not-like" |
| 398 |
] |
| 399 |
rhs: (_ |
| 400 |
(string_content) @string.regexp)) |
| 401 |
|
| 402 |
(command |
| 403 |
head: ((_) @function |
| 404 |
(#any-of? @function "nu" "$nu.current-exe")) |
| 405 |
flag: (_ |
| 406 |
name: (_) @attribute |
| 407 |
(#any-of? @attribute "c" "e" "commands" "execute")) |
| 408 |
. |
| 409 |
arg: (_ |
| 410 |
(string_content) @string.code)) |