For preserving line breaks in Design bindings, we needed to add this scalafmt config:
optIn.breaksInsideChains = true
This configuration allows aligning bindings each line:
design
.bind[X].toInstance
.bind[Y].to[YImpl]
But this configuration can't be used with newlines.source configuration like:
newlines.source = unfold
A new DI binding syntax can be formatted well without using optIn.breaksInsideChains = true:
val design: Design =
newDesign
.bindSingleton[A] // Bind A to a singleton instance of A
.bindInstance[B](new B(1)) // Bind B to a concrete instance of B
.bindImpl[A, AImpl] // Bind A to AImpl
.bindProvider{(d1: D1) => P(d1) } // Bind P using a provider function
.bindProvider{(d1: D1, d2: D2) => P(d1, d2) } // Bind P using a provider function
...
.bindProvider{(d1: D1, ..., d5: D5) => P(d1, ..., d5) } // Up to 5 arguments
For preserving line breaks in Design bindings, we needed to add this scalafmt config:
This configuration allows aligning bindings each line:
But this configuration can't be used with
newlines.source
configuration like:A new DI binding syntax can be formatted well without using
optIn.breaksInsideChains = true
: