Skip to content
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

Enable removal of blank line following topmost package statement #3630

Open
andrew-selvia opened this issue Sep 2, 2023 Discussed in #3629 · 2 comments
Open

Enable removal of blank line following topmost package statement #3630

andrew-selvia opened this issue Sep 2, 2023 Discussed in #3629 · 2 comments

Comments

@andrew-selvia
Copy link

andrew-selvia commented Sep 2, 2023

Discussed in #3629

Originally posted by andrew-selvia September 1, 2023
I've attempted to configure scalafmt to remove all newlines (including, pertinently, the one added between the topmost package statement and the next statement). Sadly, I've come up short. Prior discussion suggests that this is desired broadly. I suspect I'm in the minority.

Nonetheless, I'm curious. Is this already possible? If not, could it be made configurable?

Ideally, this code:

package org.scalafmt

import scala.collection.Map

Could be automatically formatted as follows:

package org.scalafmt
import scala.collection.Map
@andrew-selvia
Copy link
Author

andrew-selvia commented Sep 2, 2023

Re-posting from the discussion, this configuration is insufficient to achieve the desired formatting:

newlines {
  topLevelBodyIfMinStatements = []
  topLevelBodyMinStatements = 0
  topLevelStatementBlankLines = [{ blanks = -1 }]
}
runner.dialect = scala3
version = 3.7.14

@andrew-selvia
Copy link
Author

One workaround that can be leveraged is to nest top-level statements:

package org.scalafmt:
  object A

It's not ideal, but it does work.

@andrew-selvia andrew-selvia changed the title Enable removal of newline following topmost package statement Enable removal of blank line following topmost package statement Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants