28 lines
719 B
Rust
28 lines
719 B
Rust
use tree_sitter_highlight::HighlightConfiguration;
|
|
|
|
fn also_configure(mut config: HighlightConfiguration) -> (HighlightConfiguration, Vec<String>) {
|
|
let capture_names: Vec<_> = config
|
|
.query
|
|
.capture_names()
|
|
.iter()
|
|
.map(String::clone)
|
|
.collect();
|
|
config.configure(&capture_names);
|
|
|
|
(config, capture_names)
|
|
}
|
|
|
|
pub fn get_highlight_config(lang: &str) -> Option<(HighlightConfiguration, Vec<String>)> {
|
|
match lang {
|
|
"rust" => HighlightConfiguration::new(
|
|
tree_sitter_rust::language(),
|
|
tree_sitter_rust::HIGHLIGHT_QUERY,
|
|
"",
|
|
"",
|
|
)
|
|
.map(also_configure)
|
|
.ok(),
|
|
_ => None,
|
|
}
|
|
}
|