diff --git a/Cargo.lock b/Cargo.lock index 851d49181a..7f6f8c1f92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5132,6 +5132,16 @@ dependencies = [ "regex", ] +[[package]] +name = "tree-sitter-markdown" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c1cfe0396b0e500cc99067bcd2d48720eb08a077e2690194f0c3a3d105f9a0" +dependencies = [ + "cc", + "tree-sitter", +] + [[package]] name = "tree-sitter-rust" version = "0.19.0" @@ -5721,6 +5731,7 @@ dependencies = [ "tiny_http", "toml", "tree-sitter", + "tree-sitter-markdown", "tree-sitter-rust", "unindent", "url", diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index df27401711..1ff73f1c95 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -85,6 +85,7 @@ time = "0.3" tiny_http = "0.8" toml = "0.5" tree-sitter = "0.19.5" +tree-sitter-markdown = "0.7" tree-sitter-rust = "0.19.0" url = "2.2" diff --git a/crates/zed/languages/markdown/config.toml b/crates/zed/languages/markdown/config.toml new file mode 100644 index 0000000000..340189e412 --- /dev/null +++ b/crates/zed/languages/markdown/config.toml @@ -0,0 +1,8 @@ +name = "Markdown" +path_suffixes = ["md"] +brackets = [ + { start = "{", end = "}", close = true, newline = true }, + { start = "[", end = "]", close = true, newline = true }, + { start = "(", end = ")", close = true, newline = true }, + { start = "<", end = ">", close = true, newline = true }, +] diff --git a/crates/zed/src/language.rs b/crates/zed/src/language.rs index 3b77a0cf3a..e3ca38c6ef 100644 --- a/crates/zed/src/language.rs +++ b/crates/zed/src/language.rs @@ -10,14 +10,14 @@ struct LanguageDir; pub fn build_language_registry() -> LanguageRegistry { let mut languages = LanguageRegistry::default(); languages.add(Arc::new(rust())); + languages.add(Arc::new(markdown())); languages } fn rust() -> Language { let grammar = tree_sitter_rust::language(); - let rust_config = - toml::from_slice(&LanguageDir::get("rust/config.toml").unwrap().data).unwrap(); - Language::new(rust_config, grammar) + let config = toml::from_slice(&LanguageDir::get("rust/config.toml").unwrap().data).unwrap(); + Language::new(config, grammar) .with_highlights_query(load_query("rust/highlights.scm").as_ref()) .unwrap() .with_brackets_query(load_query("rust/brackets.scm").as_ref()) @@ -26,6 +26,12 @@ fn rust() -> Language { .unwrap() } +fn markdown() -> Language { + let grammar = tree_sitter_markdown::language(); + let config = toml::from_slice(&LanguageDir::get("markdown/config.toml").unwrap().data).unwrap(); + Language::new(config, grammar) +} + fn load_query(path: &str) -> Cow<'static, str> { match LanguageDir::get(path).unwrap().data { Cow::Borrowed(s) => Cow::Borrowed(str::from_utf8(s).unwrap()),