Add some more common keyword-ish capture names for highlighters

pull/261/head
Wilfred Hughes 2022-04-14 00:40:09 +07:00
parent b3872e6513
commit 47fe0cfc42
3 changed files with 19 additions and 1 deletions

@ -4,6 +4,10 @@
Added support for Kotlin.
### Display
Improved syntax highlighting for keywords.
### Command Line Interface
Difftastic now validates environment variables the same way as

@ -149,5 +149,5 @@ sample_files/yaml_before.yaml sample_files/yaml_after.yaml
1ae5db1355627f3ca607d76c3e6eed9a -
sample_files/zig_before.zig sample_files/zig_after.zig
8f02e56a47db8f889fa995a1049ab905 -
fe7f694c4223c83ecadbbf96f791ccad -

@ -633,12 +633,26 @@ fn tree_highlights(
config: &TreeSitterConfig,
) -> HighlightedNodeIds {
let mut keyword_ish_capture_ids = vec![];
// TODO: Use config.highlight_query.capture_names() to find all
// the keyword.foo captures.
if let Some(idx) = config.highlight_query.capture_index_for_name("keyword") {
keyword_ish_capture_ids.push(idx);
}
if let Some(idx) = config.highlight_query.capture_index_for_name("keyword.function") {
keyword_ish_capture_ids.push(idx);
}
if let Some(idx) = config.highlight_query.capture_index_for_name("keyword.operator") {
keyword_ish_capture_ids.push(idx);
}
if let Some(idx) = config.highlight_query.capture_index_for_name("keyword.return") {
keyword_ish_capture_ids.push(idx);
}
if let Some(idx) = config.highlight_query.capture_index_for_name("operator") {
keyword_ish_capture_ids.push(idx);
}
if let Some(idx) = config.highlight_query.capture_index_for_name("repeat") {
keyword_ish_capture_ids.push(idx);
}
if let Some(idx) = config.highlight_query.capture_index_for_name("constant") {
keyword_ish_capture_ids.push(idx);
}