diff options
| author | Riley Bruins <ribru17@hotmail.com> | 2024-07-27 07:54:27 -0700 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2024-07-27 17:17:26 +0200 |
| commit | 7cec6219c4ac5ce01ef2f29df23f8b3cebca8b09 (patch) | |
| tree | 6b8c8fb60b8cb59c5ef0056734f1cb0a3a4a16f8 | |
| parent | feat(luap): Make class captures similar to regex captures (diff) | |
| download | nvim-treesitter-7cec6219c4ac5ce01ef2f29df23f8b3cebca8b09.tar nvim-treesitter-7cec6219c4ac5ce01ef2f29df23f8b3cebca8b09.tar.gz nvim-treesitter-7cec6219c4ac5ce01ef2f29df23f8b3cebca8b09.tar.bz2 nvim-treesitter-7cec6219c4ac5ce01ef2f29df23f8b3cebca8b09.tar.lz nvim-treesitter-7cec6219c4ac5ce01ef2f29df23f8b3cebca8b09.tar.xz nvim-treesitter-7cec6219c4ac5ce01ef2f29df23f8b3cebca8b09.tar.zst nvim-treesitter-7cec6219c4ac5ce01ef2f29df23f8b3cebca8b09.zip | |
fix(query): properly apply predicate injections
I think these have been broken since the query parser update. Basically
the inner node for the string content was preventing injections because
include-children was not set.
| -rw-r--r-- | queries/query/injections.scm | 18 | ||||
| -rw-r--r-- | tests/query/injections/query/test-query-injections.scm | 27 |
2 files changed, 36 insertions, 9 deletions
diff --git a/queries/query/injections.scm b/queries/query/injections.scm index c6a74f82f..759f9b2e2 100644 --- a/queries/query/injections.scm +++ b/queries/query/injections.scm @@ -1,28 +1,28 @@ ((predicate name: (identifier) @_name parameters: (parameters - (string) @injection.content)) + (string + (string_content) @injection.content))) (#any-of? @_name "match" "not-match" "any-match" "vim-match" "not-vim-match" "any-vim-match") - (#set! injection.language "regex") - (#offset! @injection.content 0 1 0 -1)) + (#set! injection.language "regex")) ((predicate name: (identifier) @_name parameters: (parameters - (string) @injection.content)) + (string + (string_content) @injection.content))) (#any-of? @_name "lua-match" "not-lua-match" "any-lua-match") - (#set! injection.language "luap") - (#offset! @injection.content 0 1 0 -1)) + (#set! injection.language "luap")) ((predicate name: (identifier) @_name parameters: (parameters - (string) @injection.content + (string + (string_content) @injection.content) . (string) .)) (#any-of? @_name "gsub" "not-gsub") - (#set! injection.language "luap") - (#offset! @injection.content 0 1 0 -1)) + (#set! injection.language "luap")) ((comment) @injection.content (#set! injection.language "comment")) diff --git a/tests/query/injections/query/test-query-injections.scm b/tests/query/injections/query/test-query-injections.scm new file mode 100644 index 000000000..f382eddd9 --- /dev/null +++ b/tests/query/injections/query/test-query-injections.scm @@ -0,0 +1,27 @@ +; vim: ft=query +; format-ignore +(((symbol) @constant + (#not-lua-match? @constant "^_*[A-Z][A-Z0-9_]*$")) +; ^ @luap +) + +; format-ignore +(((tag + (attributes + (attribute + (attribute_name) @keyword))) + (#match? @keyword "^(:|v-bind|v-|\\@)")) +; ^ @regex +) + +((comment) @injection.language + . + [ + (string_expression + (string_fragment) @injection.content) + (indented_string_expression + (string_fragment) @injection.content) + ] + (#gsub! @injection.language "#%s*([%w%p]+)%s*" "%1") + ; ^ @luap + (#set! injection.combined)) |
