Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
language: Add auto-surround for Plain Text, JSON, and JSONC (#42631)
Mustaque Ahmedabf90cc274da
diff --git a/crates/language/src/language.rs b/crates/language/src/language.rsindex 90a55592864..a6a76dc7026 100644--- a/crates/language/src/language.rs+++ b/crates/language/src/language.rs@@ -136,6 +136,46 @@ pub static PLAIN_TEXT: LazyLock<Arc<Language>> = LazyLock::new(|| {path_suffixes: vec!["txt".to_owned()],first_line_pattern: None,},+ brackets: BracketPairConfig {+ pairs: vec![+ BracketPair {+ start: "(".to_string(),+ end: ")".to_string(),+ close: true,+ surround: true,+ newline: false,+ },+ BracketPair {+ start: "[".to_string(),+ end: "]".to_string(),+ close: true,+ surround: true,+ newline: false,+ },+ BracketPair {+ start: "{".to_string(),+ end: "}".to_string(),+ close: true,+ surround: true,+ newline: false,+ },+ BracketPair {+ start: "\"".to_string(),+ end: "\"".to_string(),+ close: true,+ surround: true,+ newline: false,+ },+ BracketPair {+ start: "'".to_string(),+ end: "'".to_string(),+ close: true,+ surround: true,+ newline: false,+ },+ ],+ disabled_scopes_by_bracket_ix: Default::default(),+ },..Default::default()},None,diff --git a/crates/languages/src/json/config.toml b/crates/languages/src/json/config.tomlindex 8caa46c8a45..d21412d7bd2 100644--- a/crates/languages/src/json/config.toml+++ b/crates/languages/src/json/config.toml@@ -4,9 +4,10 @@ path_suffixes = ["json", "flake.lock"]line_comments = ["// "]autoclose_before = ",]}"brackets = [- { start = "{", end = "}", close = true, newline = true },- { start = "[", end = "]", close = true, newline = true },- { start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },+ { start = "{", end = "}", close = true, surround = true, newline = true },+ { start = "[", end = "]", close = true, surround = true, newline = true },+ { start = "(", end = ")", close = true, surround = true, newline = false },+ { start = "\"", end = "\"", close = true, surround = true, newline = false, not_in = ["string"] },]tab_size = 2prettier_parser_name = "json"diff --git a/crates/languages/src/jsonc/config.toml b/crates/languages/src/jsonc/config.tomlindex fb86cb394aa..cb7ad38ec78 100644--- a/crates/languages/src/jsonc/config.toml+++ b/crates/languages/src/jsonc/config.toml@@ -4,9 +4,10 @@ path_suffixes = ["jsonc", "bun.lock", "tsconfig.json", "pyrightconfig.json"]line_comments = ["// "]autoclose_before = ",]}"brackets = [- { start = "{", end = "}", close = true, newline = true },- { start = "[", end = "]", close = true, newline = true },- { start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },+ { start = "{", end = "}", close = true, surround = true, newline = true },+ { start = "[", end = "]", close = true, surround = true, newline = true },+ { start = "(", end = ")", close = true, surround = true, newline = false },+ { start = "\"", end = "\"", close = true, surround = true, newline = false, not_in = ["string"] },]tab_size = 2prettier_parser_name = "jsonc"