diff --git a/lapce-core/Cargo.toml b/lapce-core/Cargo.toml index bcb81728..37bb9d6b 100644 --- a/lapce-core/Cargo.toml +++ b/lapce-core/Cargo.toml @@ -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" } diff --git a/lapce-core/src/language.rs b/lapce-core/src/language.rs index 0b67aff3..1398acd4 100644 --- a/lapce-core/src/language.rs +++ b/lapce-core/src/language.rs @@ -47,6 +47,7 @@ pub enum LapceLanguage { C, Cpp, Json, + Markdown, } impl LapceLanguage { @@ -65,6 +66,7 @@ pub fn from_path(path: &Path) -> Option { "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()