mirror of https://github.com/lapce/lapce.git
Add PHP syntax highlighting
This commit is contained in:
parent
68c91c68ad
commit
083ea286ae
|
@ -1864,6 +1864,7 @@ dependencies = [
|
|||
"tree-sitter-go",
|
||||
"tree-sitter-highlight",
|
||||
"tree-sitter-javascript",
|
||||
"tree-sitter-php",
|
||||
"tree-sitter-python",
|
||||
"tree-sitter-rust",
|
||||
"tree-sitter-toml",
|
||||
|
@ -4089,6 +4090,15 @@ dependencies = [
|
|||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-php"
|
||||
version = "0.19.1"
|
||||
source = "git+https://github.com/tree-sitter/tree-sitter-php.git#ead3e4cc5f54602a6b54826c5d6881c9a9da15af"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-python"
|
||||
version = "0.19.1"
|
||||
|
|
|
@ -17,4 +17,5 @@ tree-sitter-javascript = "0.20.0"
|
|||
tree-sitter-typescript = "0.20.0"
|
||||
tree-sitter-python = "0.19.1"
|
||||
tree-sitter-toml = "0.20.0"
|
||||
tree-sitter-php = { git = "https://github.com/tree-sitter/tree-sitter-php.git", version = "0.19.1" }
|
||||
xi-rope = { git = "https://github.com/lapce/xi-editor", features = ["serde"] }
|
||||
|
|
|
@ -43,6 +43,7 @@ pub enum LapceLanguage {
|
|||
Tsx,
|
||||
Python,
|
||||
Toml,
|
||||
Php,
|
||||
}
|
||||
|
||||
impl LapceLanguage {
|
||||
|
@ -57,6 +58,7 @@ pub fn from_path(path: &Path) -> Option<LapceLanguage> {
|
|||
"go" => LapceLanguage::Go,
|
||||
"py" => LapceLanguage::Python,
|
||||
"toml" => LapceLanguage::Toml,
|
||||
"php" => LapceLanguage::Php,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
@ -71,6 +73,7 @@ pub fn comment_token(&self) -> &str {
|
|||
LapceLanguage::Tsx => "//",
|
||||
LapceLanguage::Python => "#",
|
||||
LapceLanguage::Toml => "#",
|
||||
LapceLanguage::Php => "//",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,6 +87,7 @@ pub fn indent_unit(&self) -> &str {
|
|||
LapceLanguage::Tsx => " ",
|
||||
LapceLanguage::Python => " ",
|
||||
LapceLanguage::Toml => " ",
|
||||
LapceLanguage::Php => " ",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,6 +103,7 @@ fn tree_sitter_language(&self) -> tree_sitter::Language {
|
|||
LapceLanguage::Tsx => tree_sitter_typescript::language_tsx(),
|
||||
LapceLanguage::Python => tree_sitter_python::language(),
|
||||
LapceLanguage::Toml => tree_sitter_toml::language(),
|
||||
LapceLanguage::Php => tree_sitter_php::language(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,6 +125,7 @@ pub(crate) fn new_highlight_config(&self) -> HighlightConfiguration {
|
|||
LapceLanguage::Tsx => tree_sitter_typescript::HIGHLIGHT_QUERY,
|
||||
LapceLanguage::Python => tree_sitter_python::HIGHLIGHT_QUERY,
|
||||
LapceLanguage::Toml => tree_sitter_toml::HIGHLIGHT_QUERY,
|
||||
LapceLanguage::Php => tree_sitter_php::HIGHLIGHT_QUERY,
|
||||
};
|
||||
|
||||
HighlightConfiguration::new(language, query, "", "").unwrap()
|
||||
|
|
Loading…
Reference in New Issue