Skip to content

feat: highlight rust string interpolation macros that use format_args! #13533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nik-rev
Copy link
Contributor

@nik-rev nik-rev commented May 14, 2025

This is a revival of #12768

This adds syntax highlighting to a hard-coded set of Rust macros that accept a string literal which will be passed to format_args!.

All std macros are included as well as several crates

image

One thing that I'm not sure how to fix, is that the rust language syntax highlighter injections seems to break for other arguments when I inject rust-format-args into the 1st argument

I don't know if it's something we can do about the query or tree-house

  (macro_invocation
    macro:
      [
        (scoped_identifier
          name: (_) @_macro_name)
        (identifier) @_macro_name
      ]
    (token_tree
      . (string_literal
        (string_content) @injection.content
      )
    )
  )

Before

image

After

image

@nik-rev nik-rev changed the title feat: highlight rust macros that use format_args! feat: highlight rust string interpolation macros that use format_args! May 14, 2025
@nik-rev nik-rev marked this pull request as draft May 14, 2025 16:37
@nik-rev nik-rev marked this pull request as ready for review May 14, 2025 19:10
fix: integration test failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant