mirror of https://github.com/lapce/lapce.git
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:
parent
0919d135cb
commit
89e6dc157d
|
@ -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" }
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue