-
Notifications
You must be signed in to change notification settings - Fork 25
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
view! macro with the with! macro leads to weird formatting #97
Comments
Hi, Rust macros can take arbitrary streams of tokens. It does not have to be valid rust syntax, therefore this formatter cannot know how the contents of a macro need to be formatted. |
Is there a way to make leptosfmt to treat certain macros, such as those provided by leptos as valid? Happy to take a stab at providing a PR if you can point me in the right direction. either that, or can we make leptosfmt not modify code inside macros instead of formatting it badly? |
could you tell me more about your use case, what does |
https://github.com/leptos-rs/leptos/releases/tag/v0.5.0-rc1 From the leptos release notes:
instead of
It is a a new macro leptos provides to simplify using multiple signals with the |
Ah, I wasn't aware of Wouldn't it be more performant to do:
instead of
Is it common to use call the
I do agree that the default formatting behaviour of unknown macros is far from ideal. The least it should do is keep the original formatting intact. |
Probably, but not all code is optimized right away 🤷. The other approach is valid and functionally performant so it shouldn't be mangled at the least. As an interim, I have avoided using the imo, without this tool, using leptos is really hard due to rustfmt not being able to format view! macros, so it would be nice to support this. |
I've noticed leptosfmt tends to mess up the contents of most other macros other than |
Indeed, however this is the default behaviour of the See my previous comment in this issue:
|
Hello,
thanks for this great project!
I've noticed some inconsistent behavior with some code like this:
I might expect this to be formatting something like in the test... However this is formatted like:
It just adds spaces everywhere in the statement which actually makes the code quite unreadable for more complex examples.
This is the simplest case I found.
The text was updated successfully, but these errors were encountered: