diff --git a/Cargo.lock b/Cargo.lock index 3643b953..d07d5fa9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2178,7 +2178,7 @@ dependencies = [ [[package]] name = "tree-sitter" 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 = [ "cc", "regex", diff --git a/Cargo.toml b/Cargo.toml index 6c006fbb..f59896ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ package.helix-tui.opt-level = 2 package.helix-term.opt-level = 2 [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" [workspace.package] diff --git a/book/src/guides/indent.md b/book/src/guides/indent.md index a65ac5ac..be140384 100644 --- a/book/src/guides/indent.md +++ b/book/src/guides/indent.md @@ -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 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: - `#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 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 -written explicitly for demonstration.) \ No newline at end of file +written explicitly for demonstration.) diff --git a/book/src/guides/injection.md b/book/src/guides/injection.md index e842ae30..0a1d2c9a 100644 --- a/book/src/guides/injection.md +++ b/book/src/guides/injection.md @@ -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 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 diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index 1e90db47..c29bb3a0 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -551,7 +551,7 @@ fn query_indents<'a>( // The row/column position of the optional anchor in this query let mut anchor: Option = None; 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 { "indent" => IndentCaptureType::Indent, "indent.always" => IndentCaptureType::IndentAlways, diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 102ecb15..4e44c486 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -1727,7 +1727,7 @@ impl HighlightConfiguration { let mut local_scope_capture_index = None; for (i, name) in query.capture_names().iter().enumerate() { let i = Some(i as u32); - match name.as_str() { + match *name { "local.definition" => local_def_capture_index = i, "local.definition-value" => local_def_value_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() { let i = Some(i as u32); - match name.as_str() { + match *name { "injection.content" => injection_content_capture_index = i, "injection.language" => injection_language_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. - pub fn names(&self) -> &[String] { + pub fn names(&self) -> &[&str] { self.query.capture_names() } diff --git a/runtime/queries/tsq/highlights.scm b/runtime/queries/tsq/highlights.scm index b59514bc..5ef6bf4c 100644 --- a/runtime/queries/tsq/highlights.scm +++ b/runtime/queries/tsq/highlights.scm @@ -41,7 +41,7 @@ (capture) @label ((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 (escape_sequence) @constant.character.escape