Unnamed repository; edit this file 'description' to name the repository.
queries: Add JSON injection for Rust `json!({..})` macros
Note that this injection doesn't work currently because precedence is not handled by the current syntax highlighter. The switch to tree-house will properly handle the precedence of this pattern.
Michael Davis 12 months ago
parent 694b615 · commit 1bd7a39
-rw-r--r--runtime/queries/rust/injections.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/runtime/queries/rust/injections.scm b/runtime/queries/rust/injections.scm
index 27915e57..964eec0f 100644
--- a/runtime/queries/rust/injections.scm
+++ b/runtime/queries/rust/injections.scm
@@ -35,6 +35,18 @@
(#set! injection.language "rust")
(#set! injection.include-children))
+((macro_invocation
+ macro:
+ [
+ (scoped_identifier name: (_) @_macro_name)
+ (identifier) @_macro_name
+ ]
+ (token_tree
+ (token_tree . "{" "}" .) @injection.content))
+ (#eq? @_macro_name "json")
+ (#set! injection.language "json")
+ (#set! injection.include-children))
+
(call_expression
function: (scoped_identifier
path: (identifier) @_regex (#any-of? @_regex "Regex" "RegexBuilder")