mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-10 05:37:29 +03:00
Add a sample markdown grammar to honor the new soft wrap override
This commit is contained in:
parent
93de2bcfed
commit
cc78ae14d4
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -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",
|
||||
|
@ -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"
|
||||
|
||||
|
8
crates/zed/languages/markdown/config.toml
Normal file
8
crates/zed/languages/markdown/config.toml
Normal file
@ -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 },
|
||||
]
|
@ -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()),
|
||||
|
Loading…
Reference in New Issue
Block a user