Use standard injection.language and injection.content captures (#22268)

Closes #9656. Continuation of #9654, but with the addition of backwards
compatibility for the existing captures.

Release Notes:

- Improved Tree-sitter support with added compatibility for standard
injections captures

---------

Co-authored-by: Finn Evers <finn.evers@outlook.de>
This commit is contained in:
uncenter 2025-01-07 13:17:49 -05:00 committed by GitHub
parent f3e75d8ff6
commit d58f006498
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 181 additions and 159 deletions

View file

@ -2,6 +2,6 @@
((sigil
(sigil_name) @_sigil_name
(quoted_content) @content)
(quoted_content) @injection.content)
(#eq? @_sigil_name "H")
(#set! language "heex"))
(#set! injection.language "heex"))

View file

@ -4,10 +4,10 @@
(partial_expression_value)
(expression_value)
(ending_expression_value)
] @content)
(#set! language "elixir")
(#set! combined)
] @injection.content)
(#set! injection.language "elixir")
(#set! injection.combined)
)
((expression (expression_value) @content)
(#set! language "elixir"))
((expression (expression_value) @injection.content)
(#set! injection.language "elixir"))

View file

@ -1,7 +1,7 @@
(script_element
(raw_text) @content
(#set! "language" "javascript"))
(raw_text) @injection.content
(#set! injection.language "javascript"))
(style_element
(raw_text) @content
(#set! "language" "css"))
(raw_text) @injection.content
(#set! injection.language "css"))

View file

@ -1,9 +1,9 @@
((text) @content
(#set! "language" "html")
(#set! "combined"))
((text) @injection.content
(#set! injection.language "html")
(#set! injection.combined))
((comment) @content
(#match? @content "^/\\*\\*[^*]")
(#set! "language" "phpdoc"))
((comment) @injection.content
(#match? @injection.content "^/\\*\\*[^*]")
(#set! injection.language "phpdoc"))
((heredoc_body) (heredoc_end) @language) @content
((heredoc_body) (heredoc_end) @injection.language) @injection.content

View file

@ -1,6 +1,6 @@
; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/hcl/injections.scm
(heredoc_template
(template_literal) @content
(heredoc_identifier) @language
(#downcase! @language))
(template_literal) @injection.content
(heredoc_identifier) @injection.language
(#downcase! @injection.language))

View file

@ -1,9 +1,9 @@
; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/hcl/injections.scm
(heredoc_template
(template_literal) @content
(heredoc_identifier) @language
(#downcase! @language))
(template_literal) @injection.content
(heredoc_identifier) @injection.language
(#downcase! @injection.language))
; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/terraform/injections.scm
; inherits: hcl

View file

@ -1,9 +1,9 @@
; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/hcl/injections.scm
(heredoc_template
(template_literal) @content
(heredoc_identifier) @language
(#downcase! @language))
(template_literal) @injection.content
(heredoc_identifier) @injection.language
(#downcase! @injection.language))
; https://github.com/nvim-treesitter/nvim-treesitter/blob/ce4adf11cfe36fc5b0e5bcdce0c7c6e8fbc9798a/queries/terraform/injections.scm
; inherits: hcl