pisa-engine / pisa

PISA: Performant Indexes and Search for Academia
https://pisa-engine.github.io/pisa/book
Apache License 2.0
941 stars 65 forks source link

Update clang-format rules #557

Closed elshize closed 11 months ago

elshize commented 1 year ago

First, let's update the version of clang-format we use in CI -- the current one is 9, which is quite old by now. Since then, some options have actually been changed such that upgrading changes the formatting slightly.

So while we're doing that, I suggest updating our AlignAfterOpenBracket option to BlockIndent, which will change this:

auto long_function_with_many_arguments(
    arg1, arg2, arg3)

to this:

auto long_function_with_many_arguments(
    arg1, arg2, arg3
) -> very_long<return_type<with_templates>>

This will also affect function calls (among other things) and make scope delineation clearer.

(more info https://clang.llvm.org/docs/ClangFormatStyleOptions.html#alignafteropenbracket)

Once that is is done, I also suggest to update our brace wrapping after functions to false, since now we have that closing parenthesis.

Both of those changes will make our functions to format very similarly to Rust standard format:

auto long_function_with_many_arguments(
    arg1, arg2, arg3
) -> very_long<return_type<with_templates>> {
    return arg1 + arg2 + arg3;
}

auto short_func() {
    return "hello, world";
}
elshize commented 1 year ago

@amallia @JMMackenzie Please let me know your thoughts.

JMMackenzie commented 11 months ago

Looks like rust, sounds good to me!