Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
extension: Require that grammar names are written in snake_case (#26295)
Marshall Bowers05d3ee8555a9
diff --git a/Cargo.lock b/Cargo.lockindex 1776c4d6d8c..f31f51ee71d 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4537,6 +4537,7 @@ dependencies = ["async-tar","async-trait","collections",+ "convert_case 0.8.0","fs","futures 0.3.31","gpui",diff --git a/crates/extension/Cargo.toml b/crates/extension/Cargo.tomlindex d21c69458f7..2ca5aa30114 100644--- a/crates/extension/Cargo.toml+++ b/crates/extension/Cargo.toml@@ -17,6 +17,7 @@ async-compression.workspace = trueasync-tar.workspace = trueasync-trait.workspace = truecollections.workspace = true+convert_case.workspace = truefs.workspace = truefutures.workspace = truegpui.workspace = truediff --git a/crates/extension/src/extension_builder.rs b/crates/extension/src/extension_builder.rsindex 9a634e67606..70a4362281a 100644--- a/crates/extension/src/extension_builder.rs+++ b/crates/extension/src/extension_builder.rs@@ -4,6 +4,7 @@ use crate::{use anyhow::{anyhow, bail, Context as _, Result};use async_compression::futures::bufread::GzipDecoder;use async_tar::Archive;+use convert_case::{Case, Casing as _};use futures::io::BufReader;use futures::AsyncReadExt;use http_client::{self, AsyncBody, HttpClient};@@ -97,6 +98,11 @@ impl ExtensionBuilder {}for (grammar_name, grammar_metadata) in &extension_manifest.grammars {+ let snake_cased_grammar_name = grammar_name.to_case(Case::Snake);+ if grammar_name.as_ref() != snake_cased_grammar_name.as_str() {+ bail!("grammar name '{grammar_name}' must be written in snake_case: {snake_cased_grammar_name}");+ }+log::info!("compiling grammar {grammar_name} for extension {}",extension_dir.display()