Add markdown tree-sitter language

Requires exposing of highlights.scm, PR: https://github.com/MDeiml/tree-sitter-markdown/pull/35
This commit is contained in:
Simon Willshire 2022-03-29 10:32:13 +02:00
parent 0919d135cb
commit 89e6dc157d
2 changed files with 7 additions and 0 deletions

View File

@ -21,5 +21,6 @@ tree-sitter-php = { git = "https://github.com/tree-sitter/tree-sitter-php.git",
tree-sitter-c = "0.20.1"
tree-sitter-cpp = "0.20.0"
tree-sitter-json = "0.19.0"
tree-sitter-markdown = { git = "https://github.com/MDeiml/tree-sitter-markdown.git", version = "0.0.1" }
xi-rope = { git = "https://github.com/lapce/xi-editor", features = ["serde"] }
lapce-rpc = { path = "../lapce-rpc" }

View File

@ -47,6 +47,7 @@ pub enum LapceLanguage {
C,
Cpp,
Json,
Markdown,
}
impl LapceLanguage {
@ -65,6 +66,7 @@ pub fn from_path(path: &Path) -> Option<LapceLanguage> {
"c" | "h" => LapceLanguage::C,
"cpp" | "cxx" | "cc" | "hpp" | "hxx" => LapceLanguage::Cpp,
"json" => LapceLanguage::Json,
"md" => LapceLanguage::Markdown,
_ => return None,
})
}
@ -83,6 +85,7 @@ pub fn comment_token(&self) -> &str {
LapceLanguage::C => "//",
LapceLanguage::Cpp => "//",
LapceLanguage::Json => "",
LapceLanguage::Markdown => "",
}
}
@ -100,6 +103,7 @@ pub fn indent_unit(&self) -> &str {
LapceLanguage::C => " ",
LapceLanguage::Cpp => " ",
LapceLanguage::Json => " ",
LapceLanguage::Markdown => " ",
}
}
@ -119,6 +123,7 @@ fn tree_sitter_language(&self) -> tree_sitter::Language {
LapceLanguage::C => tree_sitter_c::language(),
LapceLanguage::Cpp => tree_sitter_cpp::language(),
LapceLanguage::Json => tree_sitter_json::language(),
LapceLanguage::Markdown => tree_sitter_markdown::language(),
}
}
@ -144,6 +149,7 @@ pub(crate) fn new_highlight_config(&self) -> HighlightConfiguration {
LapceLanguage::C => tree_sitter_c::HIGHLIGHT_QUERY,
LapceLanguage::Cpp => tree_sitter_cpp::HIGHLIGHT_QUERY,
LapceLanguage::Json => tree_sitter_json::HIGHLIGHT_QUERY,
LapceLanguage::Markdown => tree_sitter_markdown::HIGHLIGHTS_QUERY,
};
HighlightConfiguration::new(language, query, "", "").unwrap()