From cddd7875a42cb017b2751e5b6639ba322f6629df Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Thu, 3 Oct 2024 13:37:43 -0400 Subject: [PATCH] Extract Protocol Buffers support into an extension (#18704) 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. --- 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 +++++++++++ .../proto/languages}/proto/config.toml | 0 .../proto/languages}/proto/highlights.scm | 0 .../proto/languages}/proto/outline.scm | 0 9 files changed, 13 insertions(+), 16 deletions(-) create mode 100644 extensions/proto/extension.toml rename {crates/languages/src => extensions/proto/languages}/proto/config.toml (100%) rename {crates/languages/src => extensions/proto/languages}/proto/highlights.scm (100%) rename {crates/languages/src => extensions/proto/languages}/proto/outline.scm (100%) diff --git a/Cargo.lock b/Cargo.lock index 0a14f04f89..12b38967cc 100644 --- a/Cargo.lock +++ b/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" diff --git a/Cargo.toml b/Cargo.toml index 8feb93a578..a23663f5c8 100644 --- a/Cargo.toml +++ b/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" diff --git a/crates/extensions_ui/src/extension_suggest.rs b/crates/extensions_ui/src/extension_suggest.rs index 89f51fdebc..ed003f25b7 100644 --- a/crates/extensions_ui/src/extension_suggest.rs +++ b/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"]), diff --git a/crates/languages/Cargo.toml b/crates/languages/Cargo.toml index 19842efac2..dc7868ea86 100644 --- a/crates/languages/Cargo.toml +++ b/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 diff --git a/crates/languages/src/lib.rs b/crates/languages/src/lib.rs index 295df6e419..374b32c0ac 100644 --- a/crates/languages/src/lib.rs +++ b/crates/languages/src/lib.rs @@ -45,7 +45,6 @@ pub fn init(languages: Arc, 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, 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 { 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(), ) diff --git a/extensions/proto/extension.toml b/extensions/proto/extension.toml new file mode 100644 index 0000000000..a49ba7a4c4 --- /dev/null +++ b/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 "] +repository = "https://github.com/zed-industries/zed" + +[grammars.proto] +repository = "https://github.com/zed-industries/tree-sitter-proto" +commit = "0848bd30a64be48772e15fbb9d5ba8c0cc5772ad" diff --git a/crates/languages/src/proto/config.toml b/extensions/proto/languages/proto/config.toml similarity index 100% rename from crates/languages/src/proto/config.toml rename to extensions/proto/languages/proto/config.toml diff --git a/crates/languages/src/proto/highlights.scm b/extensions/proto/languages/proto/highlights.scm similarity index 100% rename from crates/languages/src/proto/highlights.scm rename to extensions/proto/languages/proto/highlights.scm diff --git a/crates/languages/src/proto/outline.scm b/extensions/proto/languages/proto/outline.scm similarity index 100% rename from crates/languages/src/proto/outline.scm rename to extensions/proto/languages/proto/outline.scm