scalameta / scalafmt

Code formatter for Scala
http://scalameta.org/scalafmt
Apache License 2.0
1.43k stars 276 forks source link

Settings to specify formatting of type parameters #2739

Closed danicheg closed 3 years ago

danicheg commented 3 years ago

Which settings in Scalafmt are about specifying formatting of type parameters? I found only newlines.beforeTypeBounds but it's not changing the formatting in my case (I've tried all variants classic/keep/fold/unfold). It'd be great if docs have a transparent paragraph about type parameters formatting 🙏🏻

Example

I have a snippet

def deploy[M[_[_]]: FunctorK, F[_], State, Event: PersistentEncoder: PersistentDecoder, K: KeyEncoder: KeyDecoder](...)
def props[M[_[_]], F[_] Async, I: KeyDecoder, State, Event: PersistentEncoder: PersistentDecoder](...)

that violates maxColumn=100, and I got code formatting

def deploy[M[_[_]]: FunctorK, F[
    _
  ], State, Event: PersistentEncoder: PersistentDecoder, K: KeyEncoder: KeyDecoder](...)
def props[M[_[_]], F[_]
    : Async, I: KeyDecoder, State, Event: PersistentEncoder: PersistentDecoder](...)

What I want is:

def deploy[M[_[_]]: FunctorK, 
  F[_], State, Event: PersistentEncoder: PersistentDecoder, K: KeyEncoder: KeyDecoder](...)
def props[M[_[_]], 
  F[_] Async, I: KeyDecoder, State, Event: PersistentEncoder: PersistentDecoder](...)

or

def deploy[
  M[_[_]]: FunctorK, 
  F[_], 
  State, 
  Event: PersistentEncoder: PersistentDecoder, K: KeyEncoder: KeyDecoder](...)
def props[
  M[_[_]], 
  F[_] Async, 
  I: KeyDecoder, 
  State, 
  Event: PersistentEncoder: PersistentDecoder](...)

Preferences

Scalafmt settings:

version = 3.0.3
maxColumn = 100
style = IntelliJ
align.arrowEnumeratorGenerator = true
align.openParenCallSite = false
unindentTopLevelOperators  = true
runner.dialect = "scala213"
newlines.beforeTypeBounds=unfold
danicheg commented 3 years ago

Holy moly guacamole, that's so neat! Thanks @kitbellew and the team!