Bump tree-sitter to latest master (#9317)

* query capture names now return `&str`s rather than `String`s
* the `#any-of?` predicate is now supported
pull/9341/head
Michael Davis 10 months ago committed by GitHub
parent 445f7a273a
commit 3011df4f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

2
Cargo.lock generated

@ -2178,7 +2178,7 @@ dependencies = [
[[package]] [[package]]
name = "tree-sitter" name = "tree-sitter"
version = "0.20.10" version = "0.20.10"
source = "git+https://github.com/tree-sitter/tree-sitter?rev=ab09ae20d640711174b8da8a654f6b3dec93da1a#ab09ae20d640711174b8da8a654f6b3dec93da1a" source = "git+https://github.com/helix-editor/tree-sitter?rev=660481dbf71413eba5a928b0b0ab8da50c1109e0#660481dbf71413eba5a928b0b0ab8da50c1109e0"
dependencies = [ dependencies = [
"cc", "cc",
"regex", "regex",

@ -36,7 +36,7 @@ package.helix-tui.opt-level = 2
package.helix-term.opt-level = 2 package.helix-term.opt-level = 2
[workspace.dependencies] [workspace.dependencies]
tree-sitter = { version = "0.20", git = "https://github.com/tree-sitter/tree-sitter", rev = "ab09ae20d640711174b8da8a654f6b3dec93da1a" } tree-sitter = { version = "0.20", git = "https://github.com/helix-editor/tree-sitter", rev = "660481dbf71413eba5a928b0b0ab8da50c1109e0" }
nucleo = "0.2.0" nucleo = "0.2.0"
[workspace.package] [workspace.package]

@ -315,6 +315,10 @@ The first argument (a capture) must/must not be equal to the second argument
The first argument (a capture) must/must not match the regex given in the The first argument (a capture) must/must not match the regex given in the
second argument (a string). second argument (a string).
- `#any-of?`/`#not-any-of?`:
The first argument (a capture) must/must not be one of the other arguments
(strings).
Additionally, we support some custom predicates for indent queries: Additionally, we support some custom predicates for indent queries:
- `#not-kind-eq?`: - `#not-kind-eq?`:
@ -366,4 +370,4 @@ Everything up to and including the closing brace gets an indent level of 1.
Then, on the closing brace, we encounter an outdent with a scope of "all", which Then, on the closing brace, we encounter an outdent with a scope of "all", which
means the first line is included, and the indent level is cancelled out on this means the first line is included, and the indent level is cancelled out on this
line. (Note these scopes are the defaults for `@indent` and `@outdent`—they are line. (Note these scopes are the defaults for `@indent` and `@outdent`—they are
written explicitly for demonstration.) written explicitly for demonstration.)

@ -54,4 +54,7 @@ The first argument (a capture) must be equal to the second argument
The first argument (a capture) must match the regex given in the The first argument (a capture) must match the regex given in the
second argument (a string). second argument (a string).
- `#any-of?` (standard):
The first argument (a capture) must be one of the other arguments (strings).
[upstream-docs]: http://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection [upstream-docs]: http://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection

@ -551,7 +551,7 @@ fn query_indents<'a>(
// The row/column position of the optional anchor in this query // The row/column position of the optional anchor in this query
let mut anchor: Option<tree_sitter::Node> = None; let mut anchor: Option<tree_sitter::Node> = None;
for capture in m.captures { for capture in m.captures {
let capture_name = query.capture_names()[capture.index as usize].as_str(); let capture_name = query.capture_names()[capture.index as usize];
let capture_type = match capture_name { let capture_type = match capture_name {
"indent" => IndentCaptureType::Indent, "indent" => IndentCaptureType::Indent,
"indent.always" => IndentCaptureType::IndentAlways, "indent.always" => IndentCaptureType::IndentAlways,

@ -1727,7 +1727,7 @@ impl HighlightConfiguration {
let mut local_scope_capture_index = None; let mut local_scope_capture_index = None;
for (i, name) in query.capture_names().iter().enumerate() { for (i, name) in query.capture_names().iter().enumerate() {
let i = Some(i as u32); let i = Some(i as u32);
match name.as_str() { match *name {
"local.definition" => local_def_capture_index = i, "local.definition" => local_def_capture_index = i,
"local.definition-value" => local_def_value_capture_index = i, "local.definition-value" => local_def_value_capture_index = i,
"local.reference" => local_ref_capture_index = i, "local.reference" => local_ref_capture_index = i,
@ -1738,7 +1738,7 @@ impl HighlightConfiguration {
for (i, name) in injections_query.capture_names().iter().enumerate() { for (i, name) in injections_query.capture_names().iter().enumerate() {
let i = Some(i as u32); let i = Some(i as u32);
match name.as_str() { match *name {
"injection.content" => injection_content_capture_index = i, "injection.content" => injection_content_capture_index = i,
"injection.language" => injection_language_capture_index = i, "injection.language" => injection_language_capture_index = i,
"injection.filename" => injection_filename_capture_index = i, "injection.filename" => injection_filename_capture_index = i,
@ -1768,7 +1768,7 @@ impl HighlightConfiguration {
} }
/// Get a slice containing all of the highlight names used in the configuration. /// Get a slice containing all of the highlight names used in the configuration.
pub fn names(&self) -> &[String] { pub fn names(&self) -> &[&str] {
self.query.capture_names() self.query.capture_names()
} }

@ -41,7 +41,7 @@
(capture) @label (capture) @label
((predicate_name) @function ((predicate_name) @function
(#match? @function "^#(eq\\?|match\\?|is\\?|is-not\\?|not-same-line\\?|not-kind-eq\\?|set!|select-adjacent!|strip!)$")) (#any-of? @function "#eq?" "#match?" "#any-of?" "#not-any-of?" "#is?" "#is-not?" "#not-same-line?" "#not-kind-eq?" "#set!" "#select-adjacent!" "#strip!"))
(predicate_name) @error (predicate_name) @error
(escape_sequence) @constant.character.escape (escape_sequence) @constant.character.escape

Loading…
Cancel
Save