Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add syntax highlighting for nu scripts
Mikayla2be34ef254f2
diff --git a/Cargo.lock b/Cargo.lockindex 4bbe29742c2..d1cd868eaac 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -8409,7 +8409,7 @@ dependencies = [[[package]]name = "tree-sitter-nu"version = "0.0.1"-source = "git+https://github.com/mikayla-maki/tree-sitter-nu/?rev=6cf9ee39ceb3da79501de7646b10e5e1da800ab8#6cf9ee39ceb3da79501de7646b10e5e1da800ab8"+source = "git+https://github.com/nushell/tree-sitter-nu?rev=786689b0562b9799ce53e824cb45a1a2a04dc673#786689b0562b9799ce53e824cb45a1a2a04dc673"dependencies = ["cc","tree-sitter",diff --git a/Cargo.toml b/Cargo.tomlindex 01f42c30621..c233c74b558 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -141,7 +141,7 @@ tree-sitter-racket = { git = "https://github.com/zed-industries/tree-sitter-racktree-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/mikayla-maki/tree-sitter-nu/", rev = "6cf9ee39ceb3da79501de7646b10e5e1da800ab8"}+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" }diff --git a/crates/zed/src/languages/nu/brackets.scm b/crates/zed/src/languages/nu/brackets.scmnew file mode 100644index 00000000000..7ede7a61926--- /dev/null+++ b/crates/zed/src/languages/nu/brackets.scm@@ -0,0 +1,4 @@+("(" @open ")" @close)+("[" @open "]" @close)+("{" @open "}" @close)+(parameter_pipes "|" @open "|" @close)diff --git a/crates/zed/src/languages/nushell/config.toml b/crates/zed/src/languages/nu/config.tomlsimilarity index 100%rename from crates/zed/src/languages/nushell/config.tomlrename to crates/zed/src/languages/nu/config.tomldiff --git a/crates/zed/src/languages/nu/highlights.scm b/crates/zed/src/languages/nu/highlights.scmnew file mode 100644index 00000000000..97f46d3879c--- /dev/null+++ b/crates/zed/src/languages/nu/highlights.scm@@ -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) @commentdiff --git a/crates/zed/src/languages/nu/indents.scm b/crates/zed/src/languages/nu/indents.scmnew file mode 100644index 00000000000..112b414aa45--- /dev/null+++ b/crates/zed/src/languages/nu/indents.scm@@ -0,0 +1,3 @@+(_ "[" "]" @end) @indent+(_ "{" "}" @end) @indent+(_ "(" ")" @end) @indentdiff --git a/crates/zed/src/languages/nushell.rs b/crates/zed/src/languages/nushell.rsdeleted file mode 100644index e69de29bb2d..00000000000diff --git a/crates/zed/src/languages/nushell/highlights.scm b/crates/zed/src/languages/nushell/highlights.scmdeleted file mode 100644index b97ed9836e6..00000000000--- a/crates/zed/src/languages/nushell/highlights.scm+++ /dev/null@@ -1,61 +0,0 @@-(string) @string-(type) @type-(value_path) @variable-(comment) @comment--(number_literal) @number-(range from: (number_literal) @number)-(range to: (number_literal) @number)--(command cmd_name: (identifier) @function)-(function_definition func_name: (identifier) @function)--[- (variable_declaration name: (identifier))- (parameter (identifier))- (flag (flag_name))- (flag (flag_shorthand_name))- (record_entry entry_name: (identifier))- (block_args block_param: (identifier))-] @property-; (parameter (identifier) @variable.parameter) ; -- alternative highlighting group?--(cmd_invocation) @embedded---((identifier) @constant- (.match? @constant "^[A-Z][A-Z\\d_]*$"))--[- "if"- "else"- "not"- "let"- "def"- "def-env"- "export"- "true"- "false"- "and"- "or"-] @keyword--[- ; "/" Not making / an operator may lead to better highlighting?- "$"- "|"- "+"- "-"- "*"- "="- "!="- "and"- "or"- "=="- ">"-] @operator--["."- ","- ";"-] @delimiter