ZIm/crates/languages/src/javascript/injections.scm
uncenter d58f006498
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>
2025-01-07 18:17:49 +00:00

60 lines
2 KiB
Scheme

(((comment) @_jsdoc_comment
(#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @injection.content
(#set! injection.language "jsdoc"))
((regex) @injection.content
(#set! injection.language "regex"))
(call_expression
function: (identifier) @_name (#eq? @_name "css")
arguments: (template_string (string_fragment) @injection.content
(#set! injection.language "css"))
)
(call_expression
function: (identifier) @_name (#eq? @_name "html")
arguments: (template_string) @injection.content
(#set! injection.language "html")
)
(call_expression
function: (identifier) @_name (#eq? @_name "js")
arguments: (template_string (string_fragment) @injection.content
(#set! injection.language "javascript"))
)
(call_expression
function: (identifier) @_name (#eq? @_name "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) @injection.content
(#set! injection.language "sql"))
)
(call_expression
function: (identifier) @_name (#eq? @_name "ts")
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) @injection.content
(#set! injection.language "yaml"))
)
(call_expression
function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
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) @injection.content
(#set! injection.language "graphql")))
)