injections.scm

 1([
 2    (line_comment)
 3    (block_comment)
 4] @injection.content
 5    (#set! injection.language "comment"))
 6
 7(macro_invocation
 8    macro: [
 9        ((identifier) @_macro_name)
10        (scoped_identifier (identifier) @_macro_name .)
11    ]
12    (token_tree) @injection.content
13    (#set! injection.language "rust"))
14
15; we need a better way for the leptos extension to declare that
16; it wants to inject inside of rust, instead of modifying the rust
17; injections to support leptos injections
18(macro_invocation
19    macro: [
20        ((identifier) @_macro_name)
21        (scoped_identifier (identifier) @_macro_name .)
22    ]
23    (#any-of? @_macro_name "view" "html")
24    (token_tree) @injection.content
25    (#set! injection.language "rstml")
26    )
27
28(macro_invocation
29    macro: [
30        ((identifier) @_macro_name)
31        (scoped_identifier (identifier) @_macro_name .)
32    ]
33    (#any-of? @_macro_name "sql")
34    (_) @injection.content
35    (#set! injection.language "sql")
36    )
37
38; lazy_regex
39(macro_invocation
40    macro: [
41        ((identifier) @_macro_name)
42        (scoped_identifier (identifier) @_macro_name .)
43    ]
44    (token_tree [
45        (string_literal (string_content) @injection.content)
46        (raw_string_literal (string_content) @injection.content)
47    ])
48    (#set! injection.language "regex")
49    (#any-of? @_macro_name "regex" "bytes_regex")
50)
51
52(call_expression
53    function: (scoped_identifier) @_fn_path
54    arguments: (arguments
55        [
56            (string_literal (string_content) @injection.content)
57            (raw_string_literal (string_content) @injection.content)
58        ]
59    )
60
61    (#match? @_fn_path ".*Regex(Builder)?::new")
62    (#set! injection.language "regex")
63)