queries: Highlight interpolations in the `rsx!` macro

pull/13932/head
Nik Revenco 2025-07-14 02:02:10 +01:00
parent b273b89249
commit e610e7dd80
1 changed files with 4 additions and 24 deletions

View File

@ -150,31 +150,11 @@
; std ; std
"assert_eq" "debug_assert_eq" "assert_ne" "debug_assert_ne" "assert_eq" "debug_assert_eq" "assert_ne" "debug_assert_ne"
; Dioxus's rsx! macro accepts string interpolation
; in all strings, across the entire token tree
"rsx"
) )
(#set! injection.language "rust-format-args-macro") (#set! injection.language "rust-format-args-macro")
(#set! injection.include-children) (#set! injection.include-children)
) )
; Dioxus' "rsx!" macro relies heavily on string interpolation as well. The strings can be nested very deeply
(
(macro_invocation
macro: [
(scoped_identifier
name: (_) @_macro_name)
(identifier) @_macro_name
]
; TODO: This only captures 1 level of string literals. But in dioxus you can have
; nested string literals. For instance:
;
; rsx! { "{hello} world" }:
; -> (token_tree (string_literal))
; rsx! { div { "{hello} world" } }
; -> (token_tree (token_tree (string_literal)))
; rsx! { div { div { "{hello} world" } } }
; -> (token_tree (token_tree (token_tree (string_literal))))
(token_tree (string_literal) @injection.content)
)
(#eq? @_macro_name "rsx")
(#set! injection.language "rust-format-args")
(#set! injection.include-children)
)