bram209 / leptosfmt

A formatter for the leptos view! macro
Apache License 2.0
258 stars 27 forks source link

Unexpected handling of formatting of !view macro #112

Open carlca opened 7 months ago

carlca commented 7 months ago

Re:Discord msg: https://discord.com/channels/1031524867910148188/1087850268034617394/1214972259626778664

I have the following !view macro...

  view! {
      <button
          on:click=move |_| {
              set_count(3);
          }
      >
          "Click me: "
          {move || count()}
      </button>
  }

and I was hoping to have it reformatted thus...

  view! {
    <button on:click=move |_| { set_count(3); } >
      "Click me: " {count}
    </button>
  }

but. leptosfmt does this...

  view! {
    <button on:click=move |_| {
        set_count(3);
    }>"Click me: " {count}</button>
  }

it's not the end of the world, and it's easily corrected, but it would be good to have this, or at least an option to have this!

This is my leptosfmt.toml at the moment. The `max_width' setting was changed at the suggestion of @brad but it doesn't seem to have made any difference.

max_width = 1000
tab_spaces = 2
attr_value_brace_style = "WhenRequired" # "Always", "AlwaysUnlessLit", "WhenRequired" or "Preserve"