Remove built-in Nu support in favor of extension (#10570)

Max Brunsfeld and Marshall created

Release Notes:

- Removed built-in Nu language support in favor of an extension.

---------

Co-authored-by: Marshall <marshall@zed.dev>

Change summary

Cargo.lock                                    |  10 
Cargo.toml                                    |   1 
crates/extensions_ui/src/extension_suggest.rs |   1 
crates/languages/Cargo.toml                   |   1 
crates/languages/src/lib.rs                   |   3 
crates/languages/src/nu.rs                    |  52 ---
crates/languages/src/nu/brackets.scm          |   4 
crates/languages/src/nu/config.toml           |  10 
crates/languages/src/nu/highlights.scm        | 284 ---------------------
crates/languages/src/nu/indents.scm           |   3 
10 files changed, 1 insertion(+), 368 deletions(-)

Detailed changes

Cargo.lock ๐Ÿ”—

@@ -5516,7 +5516,6 @@ dependencies = [
  "tree-sitter-jsdoc",
  "tree-sitter-json 0.20.0",
  "tree-sitter-markdown",
- "tree-sitter-nu",
  "tree-sitter-proto",
  "tree-sitter-python",
  "tree-sitter-regex",
@@ -10596,15 +10595,6 @@ dependencies = [
  "tree-sitter",
 ]
 
-[[package]]
-name = "tree-sitter-nu"
-version = "0.0.1"
-source = "git+https://github.com/nushell/tree-sitter-nu?rev=7dd29f9616822e5fc259f5b4ae6c4ded9a71a132#7dd29f9616822e5fc259f5b4ae6c4ded9a71a132"
-dependencies = [
- "cc",
- "tree-sitter",
-]
-
 [[package]]
 name = "tree-sitter-proto"
 version = "0.0.2"

Cargo.toml ๐Ÿ”—

@@ -334,7 +334,6 @@ tree-sitter-html = "0.19.0"
 tree-sitter-jsdoc = { git = "https://github.com/tree-sitter/tree-sitter-jsdoc", ref = "6a6cf9e7341af32d8e2b2e24a37fbfebefc3dc55" }
 tree-sitter-json = { git = "https://github.com/tree-sitter/tree-sitter-json", rev = "40a81c01a40ac48744e0c8ccabbaba1920441199" }
 tree-sitter-markdown = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "330ecab87a3e3a7211ac69bbadc19eabecdb1cca" }
-tree-sitter-nu = { git = "https://github.com/nushell/tree-sitter-nu", rev = "7dd29f9616822e5fc259f5b4ae6c4ded9a71a132" }
 tree-sitter-proto = { git = "https://github.com/rewinfrey/tree-sitter-proto", rev = "36d54f288aee112f13a67b550ad32634d0c2cb52" }
 tree-sitter-python = "0.20.2"
 tree-sitter-regex = "0.20.0"

crates/extensions_ui/src/extension_suggest.rs ๐Ÿ”—

@@ -48,6 +48,7 @@ const SUGGESTIONS_BY_EXTENSION_ID: &[(&str, &[&str])] = &[
     ("lua", &["lua"]),
     ("make", &["Makefile"]),
     ("nix", &["nix"]),
+    ("nu", &["nu"]),
     ("ocaml", &["ml", "mli"]),
     ("php", &["php"]),
     ("prisma", &["prisma"]),

crates/languages/Cargo.toml ๐Ÿ”—

@@ -48,7 +48,6 @@ tree-sitter-heex.workspace = true
 tree-sitter-jsdoc.workspace = true
 tree-sitter-json.workspace = true
 tree-sitter-markdown.workspace = true
-tree-sitter-nu.workspace = true
 tree-sitter-proto.workspace = true
 tree-sitter-python.workspace = true
 tree-sitter-regex.workspace = true

crates/languages/src/lib.rs ๐Ÿ”—

@@ -22,7 +22,6 @@ mod deno;
 mod elixir;
 mod go;
 mod json;
-mod nu;
 mod python;
 mod ruby;
 mod rust;
@@ -69,7 +68,6 @@ pub fn init(
         ("jsdoc", tree_sitter_jsdoc::language()),
         ("json", tree_sitter_json::language()),
         ("markdown", tree_sitter_markdown::language()),
-        ("nu", tree_sitter_nu::language()),
         ("proto", tree_sitter_proto::language()),
         ("python", tree_sitter_python::language()),
         ("regex", tree_sitter_regex::language()),
@@ -272,7 +270,6 @@ pub fn init(
         "yaml",
         vec![Arc::new(yaml::YamlLspAdapter::new(node_runtime.clone()))]
     );
-    language!("nu", vec![Arc::new(nu::NuLanguageServer {})]);
     language!("proto");
 
     languages.register_secondary_lsp_adapter(

crates/languages/src/nu.rs ๐Ÿ”—

@@ -1,52 +0,0 @@
-use anyhow::{anyhow, Result};
-use async_trait::async_trait;
-use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
-use lsp::LanguageServerBinary;
-use std::{any::Any, path::PathBuf};
-
-pub struct NuLanguageServer;
-
-#[async_trait(?Send)]
-impl LspAdapter for NuLanguageServer {
-    fn name(&self) -> LanguageServerName {
-        LanguageServerName("nu".into())
-    }
-
-    async fn fetch_latest_server_version(
-        &self,
-        _: &dyn LspAdapterDelegate,
-    ) -> Result<Box<dyn 'static + Any + Send>> {
-        Ok(Box::new(()))
-    }
-
-    async fn fetch_server_binary(
-        &self,
-        _version: Box<dyn 'static + Send + Any>,
-        _container_dir: PathBuf,
-        _: &dyn LspAdapterDelegate,
-    ) -> Result<LanguageServerBinary> {
-        Err(anyhow!(
-            "nu v0.87.0 or greater must be installed and available in your $PATH"
-        ))
-    }
-
-    async fn cached_server_binary(
-        &self,
-        _: PathBuf,
-        _: &dyn LspAdapterDelegate,
-    ) -> Option<LanguageServerBinary> {
-        Some(LanguageServerBinary {
-            path: "nu".into(),
-            env: None,
-            arguments: vec!["--lsp".into()],
-        })
-    }
-
-    fn can_be_reinstalled(&self) -> bool {
-        false
-    }
-
-    async fn installation_test_binary(&self, _: PathBuf) -> Option<LanguageServerBinary> {
-        None
-    }
-}

crates/languages/src/nu/config.toml ๐Ÿ”—

@@ -1,10 +0,0 @@
-name = "Nu"
-grammar = "nu"
-path_suffixes = ["nu"]
-line_comments = ["# "]
-autoclose_before = ";:.,=}])>` \n\t\""
-brackets = [
-    { start = "{", end = "}", close = true, newline = true },
-    { start = "[", end = "]", close = true, newline = true },
-    { start = "(", end = ")", close = true, newline = true },
-]

crates/languages/src/nu/highlights.scm ๐Ÿ”—

@@ -1,284 +0,0 @@
-;;; ---
-;;; keywords
-[
-    "def"
-    "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.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"
-
-        "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"
-    ] @variable.parameter
-)
-(val_binary
-    [
-       "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"
-    "//"
-    "++"
-    "**"
-    "=="
-    "!="
-    "<"
-    "<="
-    ">"
-    ">="
-    "=~"
-    "!~"
-    "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