Extract Protocol Buffers support into an extension (#18704)

Marshall Bowers created

This PR extracts the Protocol Buffers support into an extension.

Release Notes:

- Removed built-in support for Protocol Buffers, in favor of making it
available as an extension. The Protocol Buffers extension will be
suggested for download when you open a `.proto` file.

Change summary

Cargo.lock                                      | 10 ----------
Cargo.toml                                      |  1 -
crates/extensions_ui/src/extension_suggest.rs   |  1 +
crates/languages/Cargo.toml                     |  2 --
crates/languages/src/lib.rs                     |  4 +---
extensions/proto/extension.toml                 | 11 +++++++++++
extensions/proto/languages/proto/config.toml    |  0 
extensions/proto/languages/proto/highlights.scm |  0 
extensions/proto/languages/proto/outline.scm    |  0 
9 files changed, 13 insertions(+), 16 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -6386,7 +6386,6 @@ dependencies = [
  "node_runtime",
  "paths",
  "project",
- "protols-tree-sitter-proto",
  "regex",
  "rope",
  "rust-embed",
@@ -8644,15 +8643,6 @@ version = "2.28.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94"
 
-[[package]]
-name = "protols-tree-sitter-proto"
-version = "0.2.0"
-source = "git+https://github.com/zed-industries/tree-sitter-proto?rev=0848bd30a64be48772e15fbb9d5ba8c0cc5772ad#0848bd30a64be48772e15fbb9d5ba8c0cc5772ad"
-dependencies = [
- "cc",
- "tree-sitter-language",
-]
-
 [[package]]
 name = "psm"
 version = "0.1.21"

Cargo.toml 🔗

@@ -388,7 +388,6 @@ profiling = "1"
 prost = "0.9"
 prost-build = "0.9"
 prost-types = "0.9"
-protols-tree-sitter-proto = { git = "https://github.com/zed-industries/tree-sitter-proto", rev = "0848bd30a64be48772e15fbb9d5ba8c0cc5772ad" }
 pulldown-cmark = { version = "0.12.0", default-features = false }
 rand = "0.8.5"
 regex = "1.5"

crates/extensions_ui/src/extension_suggest.rs 🔗

@@ -54,6 +54,7 @@ const SUGGESTIONS_BY_EXTENSION_ID: &[(&str, &[&str])] = &[
     ("ocaml", &["ml", "mli"]),
     ("php", &["php"]),
     ("prisma", &["prisma"]),
+    ("proto", &["proto"]),
     ("purescript", &["purs"]),
     ("r", &["r", "R"]),
     ("racket", &["rkt"]),

crates/languages/Cargo.toml 🔗

@@ -21,7 +21,6 @@ load-grammars = [
     "tree-sitter-jsdoc",
     "tree-sitter-json",
     "tree-sitter-md",
-    "protols-tree-sitter-proto",
     "tree-sitter-python",
     "tree-sitter-regex",
     "tree-sitter-rust",
@@ -46,7 +45,6 @@ lsp.workspace = true
 node_runtime.workspace = true
 paths.workspace = true
 project.workspace = true
-protols-tree-sitter-proto = { workspace = true, optional = true }
 regex.workspace = true
 rope.workspace = true
 rust-embed.workspace = true

crates/languages/src/lib.rs 🔗

@@ -45,7 +45,6 @@ pub fn init(languages: Arc<LanguageRegistry>, node_runtime: NodeRuntime, cx: &mu
         ("jsonc", tree_sitter_json::LANGUAGE),
         ("markdown", tree_sitter_md::LANGUAGE),
         ("markdown-inline", tree_sitter_md::INLINE_LANGUAGE),
-        ("proto", protols_tree_sitter_proto::LANGUAGE),
         ("python", tree_sitter_python::LANGUAGE),
         ("regex", tree_sitter_regex::LANGUAGE),
         ("rust", tree_sitter_rust::LANGUAGE),
@@ -183,7 +182,6 @@ pub fn init(languages: Arc<LanguageRegistry>, node_runtime: NodeRuntime, cx: &mu
         "yaml",
         vec![Arc::new(yaml::YamlLspAdapter::new(node_runtime.clone()))]
     );
-    language!("proto");
 
     // Register globally available language servers.
     //
@@ -277,7 +275,7 @@ pub fn language(name: &str, grammar: tree_sitter::Language) -> Arc<Language> {
 fn load_config(name: &str) -> LanguageConfig {
     let config_toml = String::from_utf8(
         LanguageDir::get(&format!("{}/config.toml", name))
-            .unwrap()
+            .unwrap_or_else(|| panic!("missing config for language {:?}", name))
             .data
             .to_vec(),
     )

extensions/proto/extension.toml 🔗

@@ -0,0 +1,11 @@
+id = "proto"
+name = "Proto"
+description = "Protocol Buffers support."
+version = "0.1.0"
+schema_version = 1
+authors = ["Zed Industries <support@zed.dev>"]
+repository = "https://github.com/zed-industries/zed"
+
+[grammars.proto]
+repository = "https://github.com/zed-industries/tree-sitter-proto"
+commit = "0848bd30a64be48772e15fbb9d5ba8c0cc5772ad"