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:
parent
f3e75d8ff6
commit
d58f006498
21 changed files with 181 additions and 159 deletions
|
@ -1,7 +1,7 @@
|
|||
(preproc_def
|
||||
value: (preproc_arg) @content
|
||||
(#set! "language" "c"))
|
||||
value: (preproc_arg) @injection.content
|
||||
(#set! injection.language "c"))
|
||||
|
||||
(preproc_function_def
|
||||
value: (preproc_arg) @content
|
||||
(#set! "language" "c"))
|
||||
value: (preproc_arg) @injection.content
|
||||
(#set! injection.language "c"))
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
(preproc_def
|
||||
value: (preproc_arg) @content
|
||||
(#set! "language" "c++"))
|
||||
value: (preproc_arg) @injection.content
|
||||
(#set! injection.language "c++"))
|
||||
|
||||
(preproc_function_def
|
||||
value: (preproc_arg) @content
|
||||
(#set! "language" "c++"))
|
||||
value: (preproc_arg) @injection.content
|
||||
(#set! injection.language "c++"))
|
||||
|
||||
(raw_string_literal
|
||||
delimiter: (raw_string_delimiter) @language
|
||||
(raw_string_content) @content)
|
||||
delimiter: (raw_string_delimiter) @injection.language
|
||||
(raw_string_content) @injection.content)
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
[
|
||||
(raw_string_literal)
|
||||
(interpreted_string_literal)
|
||||
] @content
|
||||
(#set! "language" "regex")))
|
||||
] @injection.content
|
||||
(#set! injection.language "regex")))
|
||||
|
|
|
@ -1,60 +1,60 @@
|
|||
(((comment) @_jsdoc_comment
|
||||
(#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @content
|
||||
(#set! "language" "jsdoc"))
|
||||
(#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @injection.content
|
||||
(#set! injection.language "jsdoc"))
|
||||
|
||||
((regex) @content
|
||||
(#set! "language" "regex"))
|
||||
((regex) @injection.content
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "css")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "css"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "css"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "html")
|
||||
arguments: (template_string) @content
|
||||
(#set! "language" "html")
|
||||
arguments: (template_string) @injection.content
|
||||
(#set! injection.language "html")
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "js")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "javascript"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "javascript"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "json")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "json"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "json"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "sql")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "sql"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "sql"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "ts")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "typescript"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "typescript"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#match? @_name "^ya?ml$")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "yaml"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "yaml"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "graphql"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "graphql"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
|
||||
arguments: (arguments (template_string (string_fragment) @content
|
||||
(#set! "language" "graphql")))
|
||||
arguments: (arguments (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "graphql")))
|
||||
)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @language)
|
||||
(code_fence_content) @content)
|
||||
(language) @injection.language)
|
||||
(code_fence_content) @injection.content)
|
||||
|
||||
((inline) @content
|
||||
(#set! "language" "markdown-inline"))
|
||||
((inline) @injection.content
|
||||
(#set! injection.language "markdown-inline"))
|
||||
|
||||
((html_block) @content
|
||||
(#set! "language" "html"))
|
||||
((html_block) @injection.content
|
||||
(#set! injection.language "html"))
|
||||
|
||||
((minus_metadata) @content (#set! "language" "yaml"))
|
||||
((minus_metadata) @injection.content (#set! injection.language "yaml"))
|
||||
|
||||
((plus_metadata) @content (#set! "language" "toml"))
|
||||
((plus_metadata) @injection.content (#set! injection.language "toml"))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(macro_invocation
|
||||
(token_tree) @content
|
||||
(#set! "language" "rust"))
|
||||
(token_tree) @injection.content
|
||||
(#set! injection.language "rust"))
|
||||
|
||||
(macro_rule
|
||||
(token_tree) @content
|
||||
(#set! "language" "rust"))
|
||||
(token_tree) @injection.content
|
||||
(#set! injection.language "rust"))
|
||||
|
|
|
@ -1,60 +1,60 @@
|
|||
(((comment) @_jsdoc_comment
|
||||
(#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @content
|
||||
(#set! "language" "jsdoc"))
|
||||
(#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @injection.content
|
||||
(#set! injection.language "jsdoc"))
|
||||
|
||||
((regex) @content
|
||||
(#set! "language" "regex"))
|
||||
((regex) @injection.content
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "css")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "css"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "css"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "html")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "html"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "html"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "js")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "javascript"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "javascript"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "json")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "json"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "json"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "sql")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "sql"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "sql"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "ts")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "typescript"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "typescript"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#match? @_name "^ya?ml$")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "yaml"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "yaml"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "graphql"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "graphql"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
|
||||
arguments: (arguments (template_string (string_fragment) @content
|
||||
(#set! "language" "graphql")))
|
||||
arguments: (arguments (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "graphql")))
|
||||
)
|
||||
|
|
|
@ -1,64 +1,64 @@
|
|||
(((comment) @_jsdoc_comment
|
||||
(#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @content
|
||||
(#set! "language" "jsdoc"))
|
||||
(#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @injection.content
|
||||
(#set! injection.language "jsdoc"))
|
||||
|
||||
(((comment) @reference
|
||||
(#match? @reference "^///\\s+<reference\\s+types=\"\\S+\"\\s*/>\\s*$")) @content
|
||||
(#set! "language" "html"))
|
||||
(#match? @reference "^///\\s+<reference\\s+types=\"\\S+\"\\s*/>\\s*$")) @injection.content
|
||||
(#set! injection.language "html"))
|
||||
|
||||
((regex) @content
|
||||
(#set! "language" "regex"))
|
||||
((regex) @injection.content
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "css")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "css"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "css"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "html")
|
||||
arguments: (template_string) @content
|
||||
(#set! "language" "html")
|
||||
arguments: (template_string) @injection.content
|
||||
(#set! injection.language "html")
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "js")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "javascript"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "javascript"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "json")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "json"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "json"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "sql")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "sql"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "sql"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#eq? @_name "ts")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "typescript"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "typescript"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#match? @_name "^ya?ml$")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "yaml"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "yaml"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
|
||||
arguments: (template_string (string_fragment) @content
|
||||
(#set! "language" "graphql"))
|
||||
arguments: (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "graphql"))
|
||||
)
|
||||
|
||||
(call_expression
|
||||
function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
|
||||
arguments: (arguments (template_string (string_fragment) @content
|
||||
(#set! "language" "graphql")))
|
||||
arguments: (arguments (template_string (string_fragment) @injection.content
|
||||
(#set! injection.language "graphql")))
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue