Skip to content

Commit

Permalink
feat: support all format_args! macros from std
Browse files Browse the repository at this point in the history
_
  • Loading branch information
nik-rev committed Mar 8, 2025
1 parent 3268282 commit 8bdd46a
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions runtime/queries/rust/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,27 @@
"eprint"
"eprintln"
"format_args"
"todo"
"unreachable"
"unimplemented"
"compile_error"
; log
"crit"
"error"
"warn"
"info"
"debug"
"trace"
"debug"
"info"
"warn"
"error"
; anyhow
"anyhow"
"bail"
; syn
"format_ident")
"format_ident"
; indoc
"formatdoc"
"printdoc"
"eprintdoc"
"writedoc")
(#set! injection.language "rustfmt")
(#set! injection.include-children))

Expand All @@ -122,11 +131,31 @@
name: (_) @_macro_name)
(identifier) @_macro_name
]
(token_tree . (_) (string_literal) @injection.content))
(token_tree . (_) . (string_literal) @injection.content))
(#any-of? @_macro_name
; std
"write"
"writeln")
"writeln"
"assert"
"debug_assert")
(#set! injection.language "rustfmt")
(#set! injection.include-children))

; For these, only the third argument is format_args!
((macro_invocation
macro:
[
(scoped_identifier
name: (_) @_macro_name)
(identifier) @_macro_name
]
(token_tree . (_) . (_) . (string_literal) @injection.content))
(#any-of? @_macro_name
; std
"assert_eq"
"debug_assert_eq"
"assert_ne"
"debug_assert_ne")
(#set! injection.language "rustfmt")
(#set! injection.include-children))

Expand Down

0 comments on commit 8bdd46a

Please sign in to comment.