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