mirror of https://github.com/lapce/lapce.git
Added HTML tree-sitter support
This commit is contained in:
parent
dec5132441
commit
10796adc17
|
@ -1867,6 +1867,7 @@ dependencies = [
|
|||
"tree-sitter-elixir",
|
||||
"tree-sitter-go",
|
||||
"tree-sitter-highlight",
|
||||
"tree-sitter-html",
|
||||
"tree-sitter-javascript",
|
||||
"tree-sitter-json",
|
||||
"tree-sitter-php",
|
||||
|
@ -4113,6 +4114,16 @@ dependencies = [
|
|||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-html"
|
||||
version = "0.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "184e6b77953a354303dc87bf5fe36558c83569ce92606e7b382a0dc1b7443443"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-javascript"
|
||||
version = "0.20.0"
|
||||
|
|
|
@ -22,5 +22,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-html = "0.19.0"
|
||||
xi-rope = { git = "https://github.com/lapce/xi-editor", features = ["serde"] }
|
||||
lapce-rpc = { path = "../lapce-rpc" }
|
||||
|
|
|
@ -48,6 +48,7 @@ pub enum LapceLanguage {
|
|||
C,
|
||||
Cpp,
|
||||
Json,
|
||||
Html,
|
||||
}
|
||||
|
||||
impl LapceLanguage {
|
||||
|
@ -69,6 +70,7 @@ pub fn from_path(path: &Path) -> Option<LapceLanguage> {
|
|||
LapceLanguage::Cpp
|
||||
}
|
||||
"json" => LapceLanguage::Json,
|
||||
"html" | "htm" => LapceLanguage::Html,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
@ -88,6 +90,7 @@ pub fn comment_token(&self) -> &str {
|
|||
LapceLanguage::C => "//",
|
||||
LapceLanguage::Cpp => "//",
|
||||
LapceLanguage::Json => "",
|
||||
LapceLanguage::Html => "",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,6 +109,7 @@ pub fn indent_unit(&self) -> &str {
|
|||
LapceLanguage::C => " ",
|
||||
LapceLanguage::Cpp => " ",
|
||||
LapceLanguage::Json => " ",
|
||||
LapceLanguage::Html => " ",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,6 +130,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::Html => tree_sitter_html::language(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,6 +157,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::Html => tree_sitter_html::HIGHLIGHT_QUERY,
|
||||
};
|
||||
|
||||
HighlightConfiguration::new(language, query, "", "").unwrap()
|
||||
|
|
Loading…
Reference in New Issue