Skip to content

Commit 392e444

Browse files
authored
queries(rust): properly highlight Dioxus' rsx! macro (#14354)
1 parent 0ea5d87 commit 392e444

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

runtime/queries/rust/injections.scm

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -160,31 +160,11 @@
160160

161161
; std
162162
"assert_eq" "debug_assert_eq" "assert_ne" "debug_assert_ne"
163-
)
164-
(#set! injection.language "rust-format-args-macro")
165-
(#set! injection.include-children)
166-
)
167163

168-
; Dioxus' "rsx!" macro relies heavily on string interpolation as well. The strings can be nested very deeply
169-
(
170-
(macro_invocation
171-
macro: [
172-
(scoped_identifier
173-
name: (_) @_macro_name)
174-
(identifier) @_macro_name
175-
]
176-
; TODO: This only captures 1 level of string literals. But in dioxus you can have
177-
; nested string literals. For instance:
178-
;
179-
; rsx! { "{hello} world" }:
180-
; -> (token_tree (string_literal))
181-
; rsx! { div { "{hello} world" } }
182-
; -> (token_tree (token_tree (string_literal)))
183-
; rsx! { div { div { "{hello} world" } } }
184-
; -> (token_tree (token_tree (token_tree (string_literal))))
185-
(token_tree (string_literal) @injection.content)
164+
; Dioxus's rsx! macro accepts string interpolation in all
165+
; strings, across the entire token tree
166+
"rsx"
186167
)
187-
(#eq? @_macro_name "rsx")
188-
(#set! injection.language "rust-format-args")
168+
(#set! injection.language "rust-format-args-macro")
189169
(#set! injection.include-children)
190170
)

0 commit comments

Comments
 (0)