]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/nu.yaml
Add nushell syntax highlighting (#2486)
[micro.git] / runtime / syntax / nu.yaml
1 filetype: nu
2
3 detect:
4     filename: "\\.nu$"
5
6 rules:
7     - symbol: "[-+/*=<>!~%?:&|]"
8     # https://www.nushell.sh/book/command_reference.html
9     - statement: "\\b(agg-groups|agg|alias|all-false|all-true|all?|ansi gradient)\\b"
10     - statement: "\\b(ansi strip|ansi|any?|append|append|arg-max)\\b"
11     - statement: "\\b(arg-min|arg-sort|arg-true|arg-unique|as-date)\\b"
12     - statement: "\\b(as-datetime|as|benchmark|build-string|cache|cal|cd)\\b"
13     - statement: "\\b(char|clear|col|collect|columns|compact|complete)\\b"
14     - statement: "\\b(concatenate|config|config env|config nu|contains)\\b"
15     - statement: "\\b(count|count-null|cp|cumulative|date format|date humanize)\\b"
16     - statement: "\\b(date list-timezone|date now|date to-record|date to-table)\\b"
17     - statement: "\\b(date to-timezone|date|db and|db as|db col|db collect)\\b"
18     - statement: "\\b(db describe|db fn|db from|db group-by|db join|db limit)\\b"
19     - statement: "\\b(db open|db or|db order-by|db over|db query|db schema)\\b"
20     - statement: "\\b(db select|db testing|db where|db|debug|decode)\\b"
21     - statement: "\\b(def-env|default|def|describe|describe|detect columns)\\b"
22     - statement: "\\b(df-not|do|drop|drop|drop column|drop nth|drop-duplicates)\\b"
23     - statement: "\\b(drop-nulls|dtypes|du|each while|each|echo|empty?)\\b"
24     - statement: "\\b(enter|env|error make|every|exec|exit|explode)\\b"
25     - statement: "\\b(export alias|export def|export def-env|export env)\\b"
26     - statement: "\\b(export extern|export|expr-not|extern|fetch|fill-na)\\b"
27     - statement: "\\b(fill-null|filter-with|find|first|flatten)\\b"
28     - statement: "\\b(fmt|format filesize|format|for|from csv|from eml)\\b"
29     - statement: "\\b(from ics|from ini|from json|from nuon|from ods|from ssv)\\b"
30     - statement: "\\b(from toml|from tsv|from url|from vcf|from xlsx|from xml)\\b"
31     - statement: "\\b(from yaml|from yml|from|get-day|get-hour|get-minute)\\b"
32     - statement: "\\b(get-month|get-nanosecond|get-ordinal|get-second|get-week)\\b"
33     - statement: "\\b(get-weekday|get-year|get|glob|grid|group-by)\\b"
34     - statement: "\\b(group|gstat|g|hash base64|hash md5|hash sha256|hash)\\b"
35     - statement: "\\b(headers|help|hide|histogram|history|if|ignore)\\b"
36     - statement: "\\b(inc|input|insert|into binary|into bool|into datetime|into decimal)\\b"
37     - statement: "\\b(into duration|into filesize|into int|into string|into)\\b"
38     - statement: "\\b(is-admin|is-duplicated|is-in|is-not-null)\\b"
39     - statement: "\\b(is-null|is-unique|join|keep|keep until)\\b"
40     - statement: "\\b(keep while|keybindings default|keybindings listen|keybindings list)\\b"
41     - statement: "\\b(keybindings|kill|last|length|let-env|let)\\b"
42     - statement: "\\b(lines|list|lit|load-env|ls|ls-df|match|math abs)\\b"
43     - statement: "\\b(math avg|math ceil|math eval|math floor|math max)\\b"
44     - statement: "\\b(math median|math min|math mode|math product|math round)\\b"
45     - statement: "\\b(math sqrt|math stddev|math sum|math variance|math|max)\\b"
46     - statement: "\\b(mean|median|melt|merge|metadata)\\b"
47     - statement: "\\b(min|mkdir|module|move|mv|n|n-unique|n-unique)\\b"
48     - statement: "\\b(nth|nu-highlight|open|open-df|otherwise|overlay)\\b"
49     - statement: "\\b(overlay add|overlay list|overlay new|overlay remove|p)\\b"
50     - statement: "\\b(par-each|parse|path basename|path dirname|path exists)\\b"
51     - statement: "\\b(path expand|path join|path parse|path relative-to|path split)\\b"
52     - statement: "\\b(path type|path|pivot|post|prepend|print|ps|quantile)\\b"
53     - statement: "\\b(quantile|query json|query web|query xml|query|random bool)\\b"
54     - statement: "\\b(random chars|random decimal|random dice|random integer)\\b"
55     - statement: "\\b(random uuid|random|range|reduce|register|reject|rename)\\b"
56     - statement: "\\b(replace|replace-all|reverse|reverse|rm|roll down)\\b"
57     - statement: "\\b(roll left|roll right|roll up|rolling|roll|rotate)\\b"
58     - statement: "\\b(run-external|sample|save|select|select|seq|seq char)\\b"
59     - statement: "\\b(seq date|set|set-with-idx|shape|shells|shift|shuffle)\\b"
60     - statement: "\\b(size|skip until|skip while|skip|sleep|slice|sort)\\b"
61     - statement: "\\b(sort-by|source|split chars|split column|split row)\\b"
62     - statement: "\\b(split-by|split|std|std|str camel-case|str capitalize)\\b"
63     - statement: "\\b(str collect|str contains|str downcase|str ends-with|str find-replace)\\b"
64     - statement: "\\b(str index-of|str kebab-case|str length|str lpad|str pascal-case)\\b"
65     - statement: "\\b(str replace|str reverse|str rpad|str screaming-snake-case)\\b"
66     - statement: "\\b(str snake-case|str starts-with|str substring|str title-case)\\b"
67     - statement: "\\b(str to-datetime|str to-decimal|str to-int|str trim|str upcase)\\b"
68     - statement: "\\b(str-lengths|str-slice|strftime|str|sum|sys|table)\\b"
69     - statement: "\\b(take until|take while|take|term size|to csv)\\b"
70     - statement: "\\b(to html|to json|to md|to nuon|to text|to toml|to tsv)\\b"
71     - statement: "\\b(to url|to xml|to yaml|to-csv|to-df|to-dummies|to-lazy)\\b"
72     - statement: "\\b(to-lowercase|to-nu|to-parquet|to-uppercase|touch|to)\\b"
73     - statement: "\\b(transpose|tutor|unalias|uniq|unique|update|update cells)\\b"
74     - statement: "\\b(upsert|url host|url path|url query|url scheme|url)\\b"
75     - statement: "\\b(use|value-counts|var|version|view-source|watch)\\b"
76     - statement: "\\b(when|where|which|window|with-column|with-env|wrap)\\b"
77     # https://www.nushell.sh/book/types_of_data.html#booleans
78     - constant: "\\b(false|true)\\b"
79     - constant.number: "\\b[-+]?([1-9][0-9])*\\b"
80     # https://www.nushell.sh/book/types_of_data.html#binary-data
81     - constant.number: "\\b[-+]?(0(x|b|o)\\[[0-9a-fA-F ]+\\])"
82     # https://www.nushell.sh/book/types_of_data.html#file-sizes
83     - constant.number: "\\b[-+]?([0-9]+[BbMmGgTtPp][i]?[Bb]?)?\\b"
84     # https://www.nushell.sh/book/types_of_data.html#duration
85     - constant.number: "\\b[-+]?([0-9]+[num]?[s])?\\b"
86     - constant.number: "\\b[-+]?([0-9]+(sec|min|hr|day|wk))?\\b"
87     # https://www.nushell.sh/book/types_of_data.html#dates
88     - constant.number: "\\b([0-9]+[-][0-9]+[-][0-9]+([T][0-9]+[:][0-9]+[:][0-9]+)?([\\+][0-9]+[:][0-9]+)?)\\b"
89     # https://www.nushell.sh/book/types_of_data.html#ranges
90     - constant.number: "([0-9]+(\\.\\.)[0-9]+)?"
91     # https://www.nushell.sh/book/types_of_data.html#open-ended-ranges
92     - constant.number: "((\\.\\.)[0-9]+)?"
93     - constant.number: "([0-9]+(\\.\\.))?"
94     - comment:
95         start: "#"
96         end: "$"
97         rules: []
98     - comment:
99         start: "/\\*"
100         end: "\\*/"
101         rules:
102             - todo: "(FIXME|TODO|NOTE):?"
103     - constant.string:
104         start: "\""
105         end: "\""
106         skip: "\\\\."
107         rules:
108             - constant.specialChar: "\\\\."
109     - constant.string:
110         start: "'"
111         end: "'"
112         skip: "\\\\."
113         rules:
114             - constant.specialChar: "\\\\."