mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-12 08:20:05 -04:00
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.
This commit is contained in:
parent
2b4881286a
commit
7cec6219c4
2 changed files with 36 additions and 9 deletions
|
|
@ -1,28 +1,28 @@
|
||||||
((predicate
|
((predicate
|
||||||
name: (identifier) @_name
|
name: (identifier) @_name
|
||||||
parameters: (parameters
|
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")
|
(#any-of? @_name "match" "not-match" "any-match" "vim-match" "not-vim-match" "any-vim-match")
|
||||||
(#set! injection.language "regex")
|
(#set! injection.language "regex"))
|
||||||
(#offset! @injection.content 0 1 0 -1))
|
|
||||||
|
|
||||||
((predicate
|
((predicate
|
||||||
name: (identifier) @_name
|
name: (identifier) @_name
|
||||||
parameters: (parameters
|
parameters: (parameters
|
||||||
(string) @injection.content))
|
(string
|
||||||
|
(string_content) @injection.content)))
|
||||||
(#any-of? @_name "lua-match" "not-lua-match" "any-lua-match")
|
(#any-of? @_name "lua-match" "not-lua-match" "any-lua-match")
|
||||||
(#set! injection.language "luap")
|
(#set! injection.language "luap"))
|
||||||
(#offset! @injection.content 0 1 0 -1))
|
|
||||||
|
|
||||||
((predicate
|
((predicate
|
||||||
name: (identifier) @_name
|
name: (identifier) @_name
|
||||||
parameters: (parameters
|
parameters: (parameters
|
||||||
(string) @injection.content
|
(string
|
||||||
|
(string_content) @injection.content)
|
||||||
.
|
.
|
||||||
(string) .))
|
(string) .))
|
||||||
(#any-of? @_name "gsub" "not-gsub")
|
(#any-of? @_name "gsub" "not-gsub")
|
||||||
(#set! injection.language "luap")
|
(#set! injection.language "luap"))
|
||||||
(#offset! @injection.content 0 1 0 -1))
|
|
||||||
|
|
||||||
((comment) @injection.content
|
((comment) @injection.content
|
||||||
(#set! injection.language "comment"))
|
(#set! injection.language "comment"))
|
||||||
|
|
|
||||||
27
tests/query/injections/query/test-query-injections.scm
Normal file
27
tests/query/injections/query/test-query-injections.scm
Normal file
|
|
@ -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))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue