84 lines
2.1 KiB
Rust
84 lines
2.1 KiB
Rust
use tree_sitter::QueryError;
|
|
use tree_sitter_highlight::HighlightConfiguration;
|
|
|
|
use crate::register_language;
|
|
|
|
pub static COMMON_HIGHLIGHT_NAMES: &[&str] = &[
|
|
"attribute",
|
|
"constant",
|
|
"function.builtin",
|
|
"function",
|
|
"keyword",
|
|
"operator",
|
|
"property",
|
|
"punctuation",
|
|
"punctuation.bracket",
|
|
"punctuation.delimiter",
|
|
"string",
|
|
"string.special",
|
|
"tag",
|
|
"type",
|
|
"type.builtin",
|
|
"variable",
|
|
"variable.builtin",
|
|
"variable.parameter",
|
|
];
|
|
|
|
pub fn register_builtin_languages() {
|
|
register_language("rust", rust_hl_factory);
|
|
|
|
register_language("javascript", javascript_hl_factory);
|
|
register_language("js", javascript_hl_factory);
|
|
register_language("jsx", jsx_hl_factory);
|
|
|
|
register_language("regex", regex_hl_factory);
|
|
|
|
register_language("python", tree_sitter_python);
|
|
register_language("py", tree_sitter_python);
|
|
}
|
|
|
|
pub fn rust_hl_factory() -> Result<HighlightConfiguration, QueryError> {
|
|
HighlightConfiguration::new(
|
|
tree_sitter_rust::language(),
|
|
tree_sitter_rust::HIGHLIGHT_QUERY,
|
|
"",
|
|
"",
|
|
)
|
|
}
|
|
|
|
pub fn javascript_hl_factory() -> Result<HighlightConfiguration, QueryError> {
|
|
HighlightConfiguration::new(
|
|
tree_sitter_javascript::language(),
|
|
tree_sitter_javascript::HIGHLIGHT_QUERY,
|
|
tree_sitter_javascript::INJECTION_QUERY,
|
|
tree_sitter_javascript::LOCALS_QUERY,
|
|
)
|
|
}
|
|
|
|
pub fn jsx_hl_factory() -> Result<HighlightConfiguration, QueryError> {
|
|
HighlightConfiguration::new(
|
|
tree_sitter_javascript::language(),
|
|
tree_sitter_javascript::JSX_HIGHLIGHT_QUERY,
|
|
tree_sitter_javascript::INJECTION_QUERY,
|
|
tree_sitter_javascript::LOCALS_QUERY,
|
|
)
|
|
}
|
|
|
|
pub fn regex_hl_factory() -> Result<HighlightConfiguration, QueryError> {
|
|
HighlightConfiguration::new(
|
|
tree_sitter_regex::language(),
|
|
tree_sitter_regex::HIGHLIGHTS_QUERY,
|
|
"",
|
|
"",
|
|
)
|
|
}
|
|
|
|
pub fn tree_sitter_python() -> Result<HighlightConfiguration, QueryError> {
|
|
HighlightConfiguration::new(
|
|
tree_sitter_python::language(),
|
|
tree_sitter_python::HIGHLIGHT_QUERY,
|
|
"",
|
|
"",
|
|
)
|
|
}
|