micro/runtime/syntax/nu.yaml
2022-07-17 12:16:57 -07:00

115 lines
6.8 KiB
YAML

filetype: nu
detect:
filename: "\\.nu$"
rules:
- symbol: "[-+/*=<>!~%?:&|]"
# https://www.nushell.sh/book/command_reference.html
- statement: "\\b(agg-groups|agg|alias|all-false|all-true|all?|ansi gradient)\\b"
- statement: "\\b(ansi strip|ansi|any?|append|append|arg-max)\\b"
- statement: "\\b(arg-min|arg-sort|arg-true|arg-unique|as-date)\\b"
- statement: "\\b(as-datetime|as|benchmark|build-string|cache|cal|cd)\\b"
- statement: "\\b(char|clear|col|collect|columns|compact|complete)\\b"
- statement: "\\b(concatenate|config|config env|config nu|contains)\\b"
- statement: "\\b(count|count-null|cp|cumulative|date format|date humanize)\\b"
- statement: "\\b(date list-timezone|date now|date to-record|date to-table)\\b"
- statement: "\\b(date to-timezone|date|db and|db as|db col|db collect)\\b"
- statement: "\\b(db describe|db fn|db from|db group-by|db join|db limit)\\b"
- statement: "\\b(db open|db or|db order-by|db over|db query|db schema)\\b"
- statement: "\\b(db select|db testing|db where|db|debug|decode)\\b"
- statement: "\\b(def-env|default|def|describe|describe|detect columns)\\b"
- statement: "\\b(df-not|do|drop|drop|drop column|drop nth|drop-duplicates)\\b"
- statement: "\\b(drop-nulls|dtypes|du|each while|each|echo|empty?)\\b"
- statement: "\\b(enter|env|error make|every|exec|exit|explode)\\b"
- statement: "\\b(export alias|export def|export def-env|export env)\\b"
- statement: "\\b(export extern|export|expr-not|extern|fetch|fill-na)\\b"
- statement: "\\b(fill-null|filter-with|find|first|flatten)\\b"
- statement: "\\b(fmt|format filesize|format|for|from csv|from eml)\\b"
- statement: "\\b(from ics|from ini|from json|from nuon|from ods|from ssv)\\b"
- statement: "\\b(from toml|from tsv|from url|from vcf|from xlsx|from xml)\\b"
- statement: "\\b(from yaml|from yml|from|get-day|get-hour|get-minute)\\b"
- statement: "\\b(get-month|get-nanosecond|get-ordinal|get-second|get-week)\\b"
- statement: "\\b(get-weekday|get-year|get|glob|grid|group-by)\\b"
- statement: "\\b(group|gstat|g|hash base64|hash md5|hash sha256|hash)\\b"
- statement: "\\b(headers|help|hide|histogram|history|if|ignore)\\b"
- statement: "\\b(inc|input|insert|into binary|into bool|into datetime|into decimal)\\b"
- statement: "\\b(into duration|into filesize|into int|into string|into)\\b"
- statement: "\\b(is-admin|is-duplicated|is-in|is-not-null)\\b"
- statement: "\\b(is-null|is-unique|join|keep|keep until)\\b"
- statement: "\\b(keep while|keybindings default|keybindings listen|keybindings list)\\b"
- statement: "\\b(keybindings|kill|last|length|let-env|let)\\b"
- statement: "\\b(lines|list|lit|load-env|ls|ls-df|match|math abs)\\b"
- statement: "\\b(math avg|math ceil|math eval|math floor|math max)\\b"
- statement: "\\b(math median|math min|math mode|math product|math round)\\b"
- statement: "\\b(math sqrt|math stddev|math sum|math variance|math|max)\\b"
- statement: "\\b(mean|median|melt|merge|metadata)\\b"
- statement: "\\b(min|mkdir|module|move|mv|n|n-unique|n-unique)\\b"
- statement: "\\b(nth|nu-highlight|open|open-df|otherwise|overlay)\\b"
- statement: "\\b(overlay add|overlay list|overlay new|overlay remove|p)\\b"
- statement: "\\b(par-each|parse|path basename|path dirname|path exists)\\b"
- statement: "\\b(path expand|path join|path parse|path relative-to|path split)\\b"
- statement: "\\b(path type|path|pivot|post|prepend|print|ps|quantile)\\b"
- statement: "\\b(quantile|query json|query web|query xml|query|random bool)\\b"
- statement: "\\b(random chars|random decimal|random dice|random integer)\\b"
- statement: "\\b(random uuid|random|range|reduce|register|reject|rename)\\b"
- statement: "\\b(replace|replace-all|reverse|reverse|rm|roll down)\\b"
- statement: "\\b(roll left|roll right|roll up|rolling|roll|rotate)\\b"
- statement: "\\b(run-external|sample|save|select|select|seq|seq char)\\b"
- statement: "\\b(seq date|set|set-with-idx|shape|shells|shift|shuffle)\\b"
- statement: "\\b(size|skip until|skip while|skip|sleep|slice|sort)\\b"
- statement: "\\b(sort-by|source|split chars|split column|split row)\\b"
- statement: "\\b(split-by|split|std|std|str camel-case|str capitalize)\\b"
- statement: "\\b(str collect|str contains|str downcase|str ends-with|str find-replace)\\b"
- statement: "\\b(str index-of|str kebab-case|str length|str lpad|str pascal-case)\\b"
- statement: "\\b(str replace|str reverse|str rpad|str screaming-snake-case)\\b"
- statement: "\\b(str snake-case|str starts-with|str substring|str title-case)\\b"
- statement: "\\b(str to-datetime|str to-decimal|str to-int|str trim|str upcase)\\b"
- statement: "\\b(str-lengths|str-slice|strftime|str|sum|sys|table)\\b"
- statement: "\\b(take until|take while|take|term size|to csv)\\b"
- statement: "\\b(to html|to json|to md|to nuon|to text|to toml|to tsv)\\b"
- statement: "\\b(to url|to xml|to yaml|to-csv|to-df|to-dummies|to-lazy)\\b"
- statement: "\\b(to-lowercase|to-nu|to-parquet|to-uppercase|touch|to)\\b"
- statement: "\\b(transpose|tutor|unalias|uniq|unique|update|update cells)\\b"
- statement: "\\b(upsert|url host|url path|url query|url scheme|url)\\b"
- statement: "\\b(use|value-counts|var|version|view-source|watch)\\b"
- statement: "\\b(when|where|which|window|with-column|with-env|wrap)\\b"
# https://www.nushell.sh/book/types_of_data.html#booleans
- constant: "\\b(false|true)\\b"
- constant.number: "\\b[-+]?([1-9][0-9])*\\b"
# https://www.nushell.sh/book/types_of_data.html#binary-data
- constant.number: "\\b[-+]?(0(x|b|o)\\[[0-9a-fA-F ]+\\])"
# https://www.nushell.sh/book/types_of_data.html#file-sizes
- constant.number: "\\b[-+]?([0-9]+[BbMmGgTtPp][i]?[Bb]?)?\\b"
# https://www.nushell.sh/book/types_of_data.html#duration
- constant.number: "\\b[-+]?([0-9]+[num]?[s])?\\b"
- constant.number: "\\b[-+]?([0-9]+(sec|min|hr|day|wk))?\\b"
# https://www.nushell.sh/book/types_of_data.html#dates
- constant.number: "\\b([0-9]+[-][0-9]+[-][0-9]+([T][0-9]+[:][0-9]+[:][0-9]+)?([\\+][0-9]+[:][0-9]+)?)\\b"
# https://www.nushell.sh/book/types_of_data.html#ranges
- constant.number: "([0-9]+(\\.\\.)[0-9]+)?"
# https://www.nushell.sh/book/types_of_data.html#open-ended-ranges
- constant.number: "((\\.\\.)[0-9]+)?"
- constant.number: "([0-9]+(\\.\\.))?"
- comment:
start: "#"
end: "$"
rules: []
- comment:
start: "/\\*"
end: "\\*/"
rules:
- todo: "(FIXME|TODO|NOTE):?"
- constant.string:
start: "\""
end: "\""
skip: "\\\\."
rules:
- constant.specialChar: "\\\\."
- constant.string:
start: "'"
end: "'"
skip: "\\\\."
rules:
- constant.specialChar: "\\\\."