bram209 / leptosfmt

A formatter for the leptos view! macro
Apache License 2.0
274 stars 30 forks source link

Differs from rustfmt inside certain match statements #20

Closed elliotwaite closed 1 year ago

elliotwaite commented 1 year ago

When I format this code with rustfmt, I get this:

use leptos::*;

enum ExampleEnum {
    ValueOneWithAReallyLongName,
    ValueTwoWithAReallyLongName,
}

#[component]
fn Component(cx: Scope, val: ExampleEnum) -> impl IntoView {
    match val {
        ExampleEnum::ValueOneWithAReallyLongName => view! { cx,
            <div>
                <div>"Value One"</div>
            </div>
        }
        .into_view(cx),
        ExampleEnum::ValueTwoWithAReallyLongName => view! { cx,
            <div>
                <div>"Value Two"</div>
            </div>
        }
        .into_view(cx),
    }
}

When I format it with leptosfmt, I get this:

use leptos::*;

enum ExampleEnum {
    ValueOneWithAReallyLongName,
    ValueTwoWithAReallyLongName,
}

#[component]
fn Component(cx: Scope, val: ExampleEnum) -> impl IntoView {
    match val {
        ExampleEnum::ValueOneWithAReallyLongName => view! { cx,
                                                        <div>
                                                            <div>"Value One"</div>
                                                        </div>
                                                    }
        .into_view(cx),
        ExampleEnum::ValueTwoWithAReallyLongName => view! { cx,
                                                        <div>
                                                            <div>"Value Two"</div>
                                                        </div>
                                                    }
        .into_view(cx),
    }
}

I personally prefer the rustfmt version in this case, especially for more complicated HTML parts that expand even further to the right. Would it be possible to make leptosfmt use rustfmt's formatting style in these types of match statements?