Skip to content
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

Feature Request: Additional format specs #514

Open
azriel91 opened this issue Jul 18, 2023 · 0 comments
Open

Feature Request: Additional format specs #514

azriel91 opened this issue Jul 18, 2023 · 0 comments

Comments

@azriel91
Copy link

azriel91 commented Jul 18, 2023

Sublime Text Version

E.g Sublime Text 4 (Build 4150)

Rust Enhanced Version

2.25.0

Operating system

Pop OS 22.04 / Linux 6.2.6

Feature Request

Heya 👋

TL;DR: Extend or provide some way to extend RustEnhanced.sublime-syntax with additional macros which take format specs, and highlight the args in them.

Description

The indoc crate provides macros to dedent whitespace in string literals. Example:

let arg = 123;
let string = formatdoc!("
        this is some text
            and an {arg}
        more text
        ");
//                 ^^^^ The {arg} is interpreted as it would be in a `format!()` macro
//      ^^^^ The spaces on the second line are kept.
// ^^^^^ these spaces are removed by the macro.

I'd like {arg}s inside these additional macros to also be highlighted since it makes it easier to spot format strings.

There are 4 macros that do the interpolation:

  • formatdoc!($fmt, ...) — equivalent to format!(indoc!($fmt), ...)
  • printdoc!($fmt, ...) — equivalent to print!(indoc!($fmt), ...)
  • eprintdoc!($fmt, ...) — equivalent to eprint!(indoc!($fmt), ...)
  • writedoc!($dest, $fmt, ...) — equivalent to write!($dest, indoc!($fmt), ...)

I think concatdoc!(...) doesn't interpolate.

Solutioning

I could just edit RustEnhanced.sublime-syntax#L149-L182 in a local clone of the plugin, though:

  • Maybe others want it as well
  • It would be nice to not have to remember to update my local copy

There's the "wrong-but-easy" solution to just include it in the regex; I haven't worked on sublime's plugin system to know if it can be made configurable, but I suspect it's possible.

Would this be something you're happy to have in the plugin?

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

No branches or pull requests

1 participant