Add syntax highlighting for nu (#2952)
Unfortunately, their language server implementation uses [VSCode directly](https://github.com/neovim/nvim-lspconfig/issues/2592), so I don't think we can bundle it in yet. For reference, I also started prepping a [Zed repository](https://github.com/zed-industries/nushell-lsp) for serving the nu language server but have archived it since discovering the issue. Release Notes: - Added syntax highlighting for Nushell script files
This commit is contained in:
Generated
+10
@@ -8406,6 +8406,15 @@ dependencies = [
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-nu"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/nushell/tree-sitter-nu?rev=786689b0562b9799ce53e824cb45a1a2a04dc673#786689b0562b9799ce53e824cb45a1a2a04dc673"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-php"
|
||||
version = "0.19.1"
|
||||
@@ -9868,6 +9877,7 @@ dependencies = [
|
||||
"tree-sitter-lua",
|
||||
"tree-sitter-markdown",
|
||||
"tree-sitter-nix",
|
||||
"tree-sitter-nu",
|
||||
"tree-sitter-php",
|
||||
"tree-sitter-python",
|
||||
"tree-sitter-racket",
|
||||
|
||||
@@ -141,6 +141,7 @@ tree-sitter-racket = { git = "https://github.com/zed-industries/tree-sitter-rack
|
||||
tree-sitter-yaml = { git = "https://github.com/zed-industries/tree-sitter-yaml", rev = "f545a41f57502e1b5ddf2a6668896c1b0620f930"}
|
||||
tree-sitter-lua = "0.0.14"
|
||||
tree-sitter-nix = { git = "https://github.com/nix-community/tree-sitter-nix", rev = "66e3e9ce9180ae08fc57372061006ef83f0abde7" }
|
||||
tree-sitter-nu = { git = "https://github.com/nushell/tree-sitter-nu", rev = "786689b0562b9799ce53e824cb45a1a2a04dc673"}
|
||||
|
||||
[patch.crates-io]
|
||||
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "35a6052fbcafc5e5fc0f9415b8652be7dcaf7222" }
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"repositoryURL": "https://github.com/apple/swift-protobuf.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "0af9125c4eae12a4973fb66574c53a54962a9e1e",
|
||||
"version": "1.21.0"
|
||||
"revision": "ce20dc083ee485524b802669890291c0d8090170",
|
||||
"version": "1.22.1"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -132,6 +132,7 @@ tree-sitter-racket.workspace = true
|
||||
tree-sitter-yaml.workspace = true
|
||||
tree-sitter-lua.workspace = true
|
||||
tree-sitter-nix.workspace = true
|
||||
tree-sitter-nu.workspace = true
|
||||
|
||||
url = "2.2"
|
||||
urlencoding = "2.1.2"
|
||||
|
||||
@@ -170,6 +170,7 @@ pub fn init(languages: Arc<LanguageRegistry>, node_runtime: Arc<dyn NodeRuntime>
|
||||
language("elm", tree_sitter_elm::language(), vec![]);
|
||||
language("glsl", tree_sitter_glsl::language(), vec![]);
|
||||
language("nix", tree_sitter_nix::language(), vec![]);
|
||||
language("nu", tree_sitter_nu::language(), vec![]);
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
("(" @open ")" @close)
|
||||
("[" @open "]" @close)
|
||||
("{" @open "}" @close)
|
||||
(parameter_pipes "|" @open "|" @close)
|
||||
@@ -0,0 +1,9 @@
|
||||
name = "Nu"
|
||||
path_suffixes = ["nu"]
|
||||
line_comment = "# "
|
||||
autoclose_before = ";:.,=}])>` \n\t\""
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
]
|
||||
@@ -0,0 +1,302 @@
|
||||
;;; ---
|
||||
;;; keywords
|
||||
[
|
||||
"def"
|
||||
"def-env"
|
||||
"alias"
|
||||
"export-env"
|
||||
"export"
|
||||
"extern"
|
||||
"module"
|
||||
|
||||
"let"
|
||||
"let-env"
|
||||
"mut"
|
||||
"const"
|
||||
|
||||
"hide-env"
|
||||
|
||||
"source"
|
||||
"source-env"
|
||||
|
||||
"overlay"
|
||||
"register"
|
||||
|
||||
"loop"
|
||||
"while"
|
||||
"error"
|
||||
|
||||
"do"
|
||||
"if"
|
||||
"else"
|
||||
"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)
|
||||
(overlay_hide "hide" @keyword)
|
||||
(overlay_new "new" @keyword)
|
||||
(overlay_use
|
||||
"use" @keyword
|
||||
"as" @keyword
|
||||
)
|
||||
(ctrl_error "make" @keyword)
|
||||
|
||||
;;; ---
|
||||
;;; literals
|
||||
(val_number) @constant
|
||||
(val_duration
|
||||
unit: [
|
||||
"ns" "µs" "us" "ms" "sec" "min" "hr" "day" "wk"
|
||||
] @variable
|
||||
)
|
||||
(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
|
||||
)
|
||||
(val_binary
|
||||
[
|
||||
"0b"
|
||||
"0o"
|
||||
"0x"
|
||||
] @constant
|
||||
"[" @punctuation.bracket
|
||||
digit: [
|
||||
"," @punctuation.delimiter
|
||||
(hex_digit) @constant
|
||||
]
|
||||
"]" @punctuation.bracket
|
||||
) @constant
|
||||
(val_bool) @constant.builtin
|
||||
(val_nothing) @constant.builtin
|
||||
(val_string) @string
|
||||
(val_date) @constant
|
||||
(inter_escape_sequence) @constant
|
||||
(escape_sequence) @constant
|
||||
(val_interpolated [
|
||||
"$\""
|
||||
"$\'"
|
||||
"\""
|
||||
"\'"
|
||||
] @string)
|
||||
(unescaped_interpolated_content) @string
|
||||
(escaped_interpolated_content) @string
|
||||
(expr_interpolated ["(" ")"] @variable)
|
||||
|
||||
;;; ---
|
||||
;;; 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)
|
||||
|
||||
(expr_binary opr: ([
|
||||
"and"
|
||||
"or"
|
||||
"xor"
|
||||
"bit-or"
|
||||
"bit-xor"
|
||||
"bit-and"
|
||||
"bit-shl"
|
||||
"bit-shr"
|
||||
"in"
|
||||
"not-in"
|
||||
"starts-with"
|
||||
"ends-with"
|
||||
]) @keyword)
|
||||
|
||||
(where_command [
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"mod"
|
||||
"//"
|
||||
"++"
|
||||
"**"
|
||||
"=="
|
||||
"!="
|
||||
"<"
|
||||
"<="
|
||||
">"
|
||||
">="
|
||||
"=~"
|
||||
"!~"
|
||||
"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)
|
||||
(param_opt
|
||||
name: (_) @variable)
|
||||
(parameter
|
||||
param_name: (_) @variable)
|
||||
(param_cmd
|
||||
(cmd_identifier) @string)
|
||||
(param_long_flag) @variable
|
||||
(param_short_flag) @variable
|
||||
|
||||
(short_flag) @variable
|
||||
(long_flag) @variable
|
||||
|
||||
(scope_pattern [(wild_card) @function])
|
||||
|
||||
(cmd_identifier) @function
|
||||
|
||||
(command
|
||||
"^" @punctuation.delimiter
|
||||
head: (_) @function
|
||||
)
|
||||
|
||||
"where" @function
|
||||
|
||||
(path
|
||||
["." "?"] @punctuation.delimiter
|
||||
) @variable
|
||||
|
||||
(val_variable
|
||||
"$" @operator
|
||||
[
|
||||
(identifier) @variable
|
||||
"in" @type.builtin
|
||||
"nu" @type.builtin
|
||||
"env" @type.builtin
|
||||
"nothing" @type.builtin
|
||||
] ; If we have a special styling, use it here
|
||||
)
|
||||
;;; ---
|
||||
;;; types
|
||||
(flat_type) @type.builtin
|
||||
(list_type
|
||||
"list" @type
|
||||
["<" ">"] @punctuation.bracket
|
||||
)
|
||||
(collection_type
|
||||
["record" "table"] @type
|
||||
"<" @punctuation.bracket
|
||||
key: (_) @variable
|
||||
["," ":"] @punctuation.delimiter
|
||||
">" @punctuation.bracket
|
||||
)
|
||||
|
||||
(shebang) @comment
|
||||
(comment) @comment
|
||||
@@ -0,0 +1,3 @@
|
||||
(_ "[" "]" @end) @indent
|
||||
(_ "{" "}" @end) @indent
|
||||
(_ "(" ")" @end) @indent
|
||||
Reference in New Issue
Block a user