Add a sample markdown grammar to honor the new soft wrap override
This commit is contained in:
parent
93de2bcfed
commit
cc78ae14d4
4 changed files with 29 additions and 3 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
@ -5132,6 +5132,16 @@ dependencies = [
|
||||||
"regex",
|
"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]]
|
[[package]]
|
||||||
name = "tree-sitter-rust"
|
name = "tree-sitter-rust"
|
||||||
version = "0.19.0"
|
version = "0.19.0"
|
||||||
|
@ -5721,6 +5731,7 @@ dependencies = [
|
||||||
"tiny_http",
|
"tiny_http",
|
||||||
"toml",
|
"toml",
|
||||||
"tree-sitter",
|
"tree-sitter",
|
||||||
|
"tree-sitter-markdown",
|
||||||
"tree-sitter-rust",
|
"tree-sitter-rust",
|
||||||
"unindent",
|
"unindent",
|
||||||
"url",
|
"url",
|
||||||
|
|
|
@ -85,6 +85,7 @@ time = "0.3"
|
||||||
tiny_http = "0.8"
|
tiny_http = "0.8"
|
||||||
toml = "0.5"
|
toml = "0.5"
|
||||||
tree-sitter = "0.19.5"
|
tree-sitter = "0.19.5"
|
||||||
|
tree-sitter-markdown = "0.7"
|
||||||
tree-sitter-rust = "0.19.0"
|
tree-sitter-rust = "0.19.0"
|
||||||
url = "2.2"
|
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 {
|
pub fn build_language_registry() -> LanguageRegistry {
|
||||||
let mut languages = LanguageRegistry::default();
|
let mut languages = LanguageRegistry::default();
|
||||||
languages.add(Arc::new(rust()));
|
languages.add(Arc::new(rust()));
|
||||||
|
languages.add(Arc::new(markdown()));
|
||||||
languages
|
languages
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rust() -> Language {
|
fn rust() -> Language {
|
||||||
let grammar = tree_sitter_rust::language();
|
let grammar = tree_sitter_rust::language();
|
||||||
let rust_config =
|
let config = toml::from_slice(&LanguageDir::get("rust/config.toml").unwrap().data).unwrap();
|
||||||
toml::from_slice(&LanguageDir::get("rust/config.toml").unwrap().data).unwrap();
|
Language::new(config, grammar)
|
||||||
Language::new(rust_config, grammar)
|
|
||||||
.with_highlights_query(load_query("rust/highlights.scm").as_ref())
|
.with_highlights_query(load_query("rust/highlights.scm").as_ref())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_brackets_query(load_query("rust/brackets.scm").as_ref())
|
.with_brackets_query(load_query("rust/brackets.scm").as_ref())
|
||||||
|
@ -26,6 +26,12 @@ fn rust() -> Language {
|
||||||
.unwrap()
|
.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> {
|
fn load_query(path: &str) -> Cow<'static, str> {
|
||||||
match LanguageDir::get(path).unwrap().data {
|
match LanguageDir::get(path).unwrap().data {
|
||||||
Cow::Borrowed(s) => Cow::Borrowed(str::from_utf8(s).unwrap()),
|
Cow::Borrowed(s) => Cow::Borrowed(str::from_utf8(s).unwrap()),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue