mirror of https://github.com/helix-editor/helix
Update tree-sitter grammar for nu (#7873)
* Update tree-sitter grammar for nu Change tree-sitter grammar for nushell to 'officially' maintained by nushell project https://github.com/nushell/tree-sitter-nu. Update to the latest version. Replace queries with supported * Restore injection queries for nu Restore injection.scm queries for nushell tree-sitter grammarpull/7233/head^2
parent
48eb0d4792
commit
1077630834
@ -1,4 +0,0 @@
|
||||
[
|
||||
(function_definition)
|
||||
(block)
|
||||
] @fold
|
@ -1,55 +1,287 @@
|
||||
(string) @string
|
||||
(type) @type
|
||||
(value_path) @variable
|
||||
(comment) @comment
|
||||
|
||||
(number_literal) @constant.numeric
|
||||
(range from: (number_literal) @constant.numeric)
|
||||
(range to: (number_literal) @constant.numeric)
|
||||
;;; ---
|
||||
;;; keywords
|
||||
[
|
||||
"def"
|
||||
"def-env"
|
||||
"alias"
|
||||
"export-env"
|
||||
"export"
|
||||
"extern"
|
||||
"module"
|
||||
|
||||
(command cmd_name: (identifier) @function)
|
||||
(function_definition func_name: (identifier) @function)
|
||||
"let"
|
||||
"let-env"
|
||||
"mut"
|
||||
"const"
|
||||
|
||||
[
|
||||
(variable_declaration name: (identifier))
|
||||
(parameter (identifier))
|
||||
(flag (flag_name))
|
||||
(flag (flag_shorthand_name))
|
||||
(record_entry entry_name: (identifier))
|
||||
(block_args block_param: (identifier))
|
||||
] @variable.other.member
|
||||
; (parameter (identifier) @variable.parameter) ; -- alternative highlighting group?
|
||||
"hide-env"
|
||||
|
||||
(cmd_invocation) @embedded
|
||||
"source"
|
||||
"source-env"
|
||||
|
||||
"overlay"
|
||||
"register"
|
||||
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
|
||||
"loop"
|
||||
"while"
|
||||
"error"
|
||||
|
||||
[
|
||||
"do"
|
||||
"if"
|
||||
"else"
|
||||
"let"
|
||||
"def"
|
||||
"export"
|
||||
"try"
|
||||
"catch"
|
||||
"match"
|
||||
|
||||
"break"
|
||||
"continue"
|
||||
"return"
|
||||
|
||||
] @keyword
|
||||
|
||||
(hide_mod "hide" @keyword)
|
||||
(decl_use "use" @keyword)
|
||||
|
||||
(ctrl_for
|
||||
"for" @keyword
|
||||
"in" @keyword
|
||||
)
|
||||
(overlay_list "list" @keyword.storage.modifier)
|
||||
(overlay_hide "hide" @keyword.storage.modifier)
|
||||
(overlay_new "new" @keyword.storage.modifier)
|
||||
(overlay_use
|
||||
"use" @keyword.storage.modifier
|
||||
"as" @keyword
|
||||
)
|
||||
(ctrl_error "make" @keyword.storage.modifier)
|
||||
|
||||
;;; ---
|
||||
;;; literals
|
||||
(val_number) @constant.numeric
|
||||
(val_duration
|
||||
unit: [
|
||||
"ns" "µs" "us" "ms" "sec" "min" "hr" "day" "wk"
|
||||
] @variable.parameter
|
||||
)
|
||||
(val_filesize
|
||||
unit: [
|
||||
"b" "B"
|
||||
|
||||
"kb" "kB" "Kb" "KB"
|
||||
"mb" "mB" "Mb" "MB"
|
||||
"gb" "gB" "Gb" "GB"
|
||||
"tb" "tB" "Tb" "TB"
|
||||
"pb" "pB" "Pb" "PB"
|
||||
"eb" "eB" "Eb" "EB"
|
||||
"zb" "zB" "Zb" "ZB"
|
||||
|
||||
"kib" "kiB" "kIB" "kIb" "Kib" "KIb" "KIB"
|
||||
"mib" "miB" "mIB" "mIb" "Mib" "MIb" "MIB"
|
||||
"gib" "giB" "gIB" "gIb" "Gib" "GIb" "GIB"
|
||||
"tib" "tiB" "tIB" "tIb" "Tib" "TIb" "TIB"
|
||||
"pib" "piB" "pIB" "pIb" "Pib" "PIb" "PIB"
|
||||
"eib" "eiB" "eIB" "eIb" "Eib" "EIb" "EIB"
|
||||
"zib" "ziB" "zIB" "zIb" "Zib" "ZIb" "ZIB"
|
||||
] @variable.parameter
|
||||
)
|
||||
(val_binary
|
||||
[
|
||||
; "/" Not making / an operator may lead to better highlighting?
|
||||
"$"
|
||||
"|"
|
||||
"0b"
|
||||
"0o"
|
||||
"0x"
|
||||
] @constant.numeric
|
||||
"[" @punctuation.bracket
|
||||
digit: [
|
||||
"," @punctuation.delimiter
|
||||
(hex_digit) @constant.number
|
||||
]
|
||||
"]" @punctuation.bracket
|
||||
) @constant.numeric
|
||||
(val_bool) @constant.builtin
|
||||
(val_nothing) @constant.builtin
|
||||
(val_string) @string
|
||||
(val_date) @constant.number
|
||||
(inter_escape_sequence) @constant.character.escape
|
||||
(escape_sequence) @constant.character.escape
|
||||
(val_interpolated [
|
||||
"$\""
|
||||
"$\'"
|
||||
"\""
|
||||
"\'"
|
||||
] @string)
|
||||
(unescaped_interpolated_content) @string
|
||||
(escaped_interpolated_content) @string
|
||||
(expr_interpolated ["(" ")"] @variable.parameter)
|
||||
|
||||
;;; ---
|
||||
;;; operators
|
||||
(expr_binary [
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"="
|
||||
"/"
|
||||
"mod"
|
||||
"//"
|
||||
"++"
|
||||
"**"
|
||||
"=="
|
||||
"!="
|
||||
"&&"
|
||||
"||"
|
||||
"<"
|
||||
"<="
|
||||
">"
|
||||
">="
|
||||
"=~"
|
||||
"!~"
|
||||
"and"
|
||||
"or"
|
||||
"xor"
|
||||
"bit-or"
|
||||
"bit-xor"
|
||||
"bit-and"
|
||||
"bit-shl"
|
||||
"bit-shr"
|
||||
"in"
|
||||
"not-in"
|
||||
"starts-with"
|
||||
"ends-with"
|
||||
] @operator )
|
||||
|
||||
(where_command [
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"mod"
|
||||
"//"
|
||||
"++"
|
||||
"**"
|
||||
"=="
|
||||
"!="
|
||||
"<"
|
||||
"<="
|
||||
">"
|
||||
] @operator
|
||||
">="
|
||||
"=~"
|
||||
"!~"
|
||||
"and"
|
||||
"or"
|
||||
"xor"
|
||||
"bit-or"
|
||||
"bit-xor"
|
||||
"bit-and"
|
||||
"bit-shl"
|
||||
"bit-shr"
|
||||
"in"
|
||||
"not-in"
|
||||
"starts-with"
|
||||
"ends-with"
|
||||
] @operator)
|
||||
|
||||
(assignment [
|
||||
"="
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"++="
|
||||
] @operator)
|
||||
|
||||
(expr_unary ["not" "-"] @operator)
|
||||
|
||||
(val_range [
|
||||
".."
|
||||
"..="
|
||||
"..<"
|
||||
] @operator)
|
||||
|
||||
["."
|
||||
["=>" "=" "|"] @operator
|
||||
|
||||
[
|
||||
"o>" "out>"
|
||||
"e>" "err>"
|
||||
"e+o>" "err+out>"
|
||||
"o+e>" "out+err>"
|
||||
] @special
|
||||
|
||||
;;; ---
|
||||
;;; punctuation
|
||||
[
|
||||
","
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
(param_short_flag "-" @punctuation.delimiter)
|
||||
(param_long_flag ["--"] @punctuation.delimiter)
|
||||
(long_flag ["--"] @punctuation.delimiter)
|
||||
(param_rest "..." @punctuation.delimiter)
|
||||
(param_type [":"] @punctuation.special)
|
||||
(param_value ["="] @punctuation.special)
|
||||
(param_cmd ["@"] @punctuation.special)
|
||||
(param_opt ["?"] @punctuation.special)
|
||||
|
||||
[
|
||||
"(" ")"
|
||||
"{" "}"
|
||||
"[" "]"
|
||||
] @punctuation.bracket
|
||||
|
||||
(val_record
|
||||
(record_entry ":" @punctuation.delimiter))
|
||||
;;; ---
|
||||
;;; identifiers
|
||||
(param_rest
|
||||
name: (_) @variable.parameter)
|
||||
(param_opt
|
||||
name: (_) @variable.parameter)
|
||||
(parameter
|
||||
param_name: (_) @variable.parameter)
|
||||
(param_cmd
|
||||
(cmd_identifier) @string)
|
||||
(param_long_flag) @variable.parameter
|
||||
(param_short_flag) @variable.parameter
|
||||
|
||||
(short_flag) @variable.parameter
|
||||
(long_flag) @variable.parameter
|
||||
|
||||
(scope_pattern [(wild_card) @function])
|
||||
|
||||
(cmd_identifier) @function
|
||||
|
||||
(command
|
||||
"^" @punctuation.delimiter
|
||||
head: (_) @function
|
||||
)
|
||||
|
||||
"where" @function
|
||||
|
||||
(path
|
||||
["." "?"] @punctuation.delimiter
|
||||
) @variable.parameter
|
||||
|
||||
(val_variable
|
||||
"$" @variable.parameter
|
||||
[
|
||||
(identifier) @namespace
|
||||
"in"
|
||||
"nu"
|
||||
"env"
|
||||
"nothing"
|
||||
] @special
|
||||
)
|
||||
;;; ---
|
||||
;;; types
|
||||
(flat_type) @type.builtin
|
||||
(list_type
|
||||
"list" @type.enum
|
||||
["<" ">"] @punctuation.bracket
|
||||
)
|
||||
(collection_type
|
||||
["record" "table"] @type.enum
|
||||
"<" @punctuation.bracket
|
||||
key: (_) @variable.parameter
|
||||
["," ":"] @punctuation.delimiter
|
||||
">" @punctuation.bracket
|
||||
)
|
||||
|
||||
(shebang) @comment
|
||||
(comment) @comment
|
||||
|
@ -1,13 +0,0 @@
|
||||
; Scopes
|
||||
(function_definition) @scope
|
||||
|
||||
; Definitions
|
||||
(variable_declaration
|
||||
name: (identifier) @definition.var)
|
||||
|
||||
(function_definition
|
||||
func_name: (identifier) @definition.function)
|
||||
|
||||
; References
|
||||
(value_path) @reference
|
||||
(word) @reference
|
Loading…
Reference in New Issue