aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries/tsq
diff options
context:
space:
mode:
authorMichael Davis2022-07-05 11:01:05 +0000
committerGitHub2022-07-05 11:01:05 +0000
commitaacd0c8aa542ac0316569ae062966362222ff4bf (patch)
tree906ef0c7189fcfc7e0538ab9405eb33939b67ead /runtime/queries/tsq
parentd78354c537e00ddb0976efad1df49c90a224f107 (diff)
Update TSQ queries (#2960)
A few changes to make TSQ highlights better: * A parsing error has been fixed in the grammar itself * Previously tree-sitter-tsq did not parse the variables in predicates like `(#set! injection.language "javascript")` * Theme nodes as `tag` * The newly added node to the parser (from the above fix) is `variable` which takes over the `variable` capture from nodes * Highlight known predicates as `function` and unsupported predicates as `error` * This may help when translating queries from nvim-treesitter. For example `#any-of?` is a common one used in nvim-treesitter queries but not implemented in Helix or tree-sitter-cli. * Inject tree-sitter-regex into `#match?` predicates
Diffstat (limited to 'runtime/queries/tsq')
-rw-r--r--runtime/queries/tsq/highlights.scm9
-rw-r--r--runtime/queries/tsq/injections.scm6
2 files changed, 12 insertions, 3 deletions
diff --git a/runtime/queries/tsq/highlights.scm b/runtime/queries/tsq/highlights.scm
index fd5917fb..c655b994 100644
--- a/runtime/queries/tsq/highlights.scm
+++ b/runtime/queries/tsq/highlights.scm
@@ -6,7 +6,7 @@
; highlight inheritance comments
((query . (comment) @keyword.directive)
- (#match? @keyword.directive "^;\ +inherits *:"))
+ (#match? @keyword.directive "^; +inherits *:"))
[
"("
@@ -40,8 +40,11 @@
(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!)$"))
+(predicate_name) @error
(escape_sequence) @constant.character.escape
-(node_name) @variable
+(node_name) @tag
+(variable) @variable
diff --git a/runtime/queries/tsq/injections.scm b/runtime/queries/tsq/injections.scm
index 321c90ad..64404557 100644
--- a/runtime/queries/tsq/injections.scm
+++ b/runtime/queries/tsq/injections.scm
@@ -1,2 +1,8 @@
((comment) @injection.content
(#set! injection.language "comment"))
+
+((predicate
+ (predicate_name) @_predicate
+ (string) @injection.content)
+ (#eq? @_predicate "#match?")
+ (#set! injection.language "regex"))