You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a class/object/trait extends anything, the same general rule applies, put it on one line unless it goes over about 100 characters, and then put each item on its own line with trailing commas; closing parenthesis provides visual separation between constructor arguments and extensions; empty line should be added to further separate extensions from class implementation:
I believe this is related to issues brought up in #1653. In that issue, it was proposed to add a newlines.alwaysInsideTopLevelStatements configuration option.
The style guide seems to suggest adding the empty line for visual separation when extensions are added to the class.
Unfortunately, newlines.topLevelStatements only seems to focus on spacing between the top level elements and only when newlines.topLevelStatementsMinBreaks is meant. While I could partially achieve the desired result by setting newlines.topLevelStatementsMinBreaks to 0, it's not ideal because:
Everything ends up being separated by a newline
It violates the first example where a newline isn't needed when there is no extensions
I think what's needed is something along the lines of newlines.alwaysAfterClassExtension.
The text was updated successfully, but these errors were encountered:
Steps
Given code like this:
When I run scalafmt like this:
Problem
Scalafmt formats code like this:
Expectation
I would like the formatted output to look like this:
Notes
The main issue is I'm trying to achieve the formatting recommended by the official scala style guide for classes.
The docs provide two examples. The first without an extends statement:
The second, with extends:
The exact wording is:
I believe this is related to issues brought up in #1653. In that issue, it was proposed to add a
newlines.alwaysInsideTopLevelStatements
configuration option.The style guide seems to suggest adding the empty line for visual separation when extensions are added to the class.
Unfortunately,
newlines.topLevelStatements
only seems to focus on spacing between the top level elements and only whennewlines.topLevelStatementsMinBreaks
is meant. While I could partially achieve the desired result by settingnewlines.topLevelStatementsMinBreaks
to0
, it's not ideal because:I think what's needed is something along the lines of
newlines.alwaysAfterClassExtension
.The text was updated successfully, but these errors were encountered: