If true AND bin-packing is true, then call-site arguments won't be aligned by the opening parenthesis. For example, this output will be disallowed function(a, b, c)
Same as openParenCallSite, except definition site.
The tokens to vertically align by. The "owner" is the scala.meta.Tree.getClass.getName of the deepest tree node that "owns" the token to align by. Examples: align.tokens = ["="] // align = owned by any tree node (not recommended) align.tokens = [ { code = "=", owner = "Param" } // align = when owned by parameter tree nodes ] Pro tip. if you use for example style = defaultWithAlign and want to add one extra token (for example "|>") to align by, write align.tokens.add = [ "|> ] NOTE. Adding more alignment tokens may potentially decrease the vertical alignment in formatted output. Customize at your own risk, I recommend you try and stick to the default settings.
If true, aligns by <- in for comprehensions.
If true, aligns by ( in if/while/for. If false, indents by continuation indent at call site.
Customize which token kinds can align together. By default, only tokens with
the same Token.productPrefix
align. To for example align = and <-,
set the values to:
Map("Equals" -> "Assign", "LeftArrow" -> "Assign")
Note. Requires mixedTokens to be true.
Customize which tree kinds can align together. By default, only trees with
the same Tree.productPrefix
align. To for example align Defn.Val and
Defn.Var, set the values to:
Map("Defn.Var" -> "Assign", "Defn.Val" -> "Assign")
Note. Requires mixedOwners to be true.
Configuration option for aligning tokens.
Configuration option for aligning tokens.
string literal value of the token to align by.
regexp for class name of scala.meta.Tree "owner" of code.
DO NOT USE! This option is buggy for complicated expressions. The only reason this option exists is to support the literalArgumentLists option, which enables callSite only for simple expressions. If true, will fit as many arguments on each line, only breaking at commas. If false, a function call's arguments will either be all on the same line or will have one line each.
Same as unsafeCallSite, except for definition site.
Parent constructors are C and D in "class A extends B with C and D". If true, scalafmt will fit as many parent constructors on a single line. If false, each parent constructor gets its own line.
If true, automatically sets the style to bin-pack for argument lists that only consist of literals.
Argument list must be longer than this setting to be eligible for literalArgumentLists.
Regexes for literal type names. For example, "Int" or "Byte".
Regexes for literal to exclude from literalArgumentLists.
indentation around function calls, etc.
indentation around class/def
indentation before extends
An event that happens while formatting a file.
ADT representing import selectors settings, specifically pertaining to the handling when multiple names are imported from the same package.
ADT representing import selectors settings, specifically pertaining to the handling when multiple names are imported from the same package.
When org.scalafmt.config.ImportSelectors.noBinPack is selected, imports are organized such that each line contains a single name imported from the base package:
// max columns | import org.{ Aaaa, Bbbb, C, D, Eeee }
When org.scalafmt.config.ImportSelectors.binPack is selected, imports are organized such that each line contains as many names as will fit within the column limit:
// max columns | import org.{ Aaaa, Bbbb, C, D, Eeee }
When org.scalafmt.config.ImportSelectors.singleLine is selected, imports are organized such that all names for a single package are arranged on a single line:
// max columns | import org.{Aaaa, Bbbb, C, D, Eeee}
If true, a newline will never be placed in front of js.native.
If true, scalafmt may choose to put a newline before colon : at defs.
If true, adds a penalty to newlines before a dot starting a select chain of length one and argument list. The penalty matches the number of arguments to the select chain application.
// If true, favor logger.elem(a, b, c) // instead of logger .elem(a, b, c) // penalty is proportional to argument count, example: logger.elem(a, b, c) // penalty 2 logger.elem(a, b, c, d) // penalty 3, etc.
If false, matches pre-v0.5 behavior. Note. this option may be removed in a future release.
If true, puts a newline after the open brace and the parameters list of an anonymous function. For example something.map { n => consume(n) }
If never
(default), it will remove any extra lines below curly lambdas
something.map { x =>
f(x)
}
will become
something.map { x =>
f(x)
}
If always
, it will always add one empty line (opposite of never
).
If preserve
, and there isn't an empty line, it will keep it as it is.
If there is one or more empty lines, it will place a single empty line.
if true, add a new line between the end of a curly if and the following else. For example if(someCond) { // ... } else //...
If true, add a newline before the body of a multiline def without curly braces. See #1126 for discussion. For example,
// newlines.alwaysBeforeMultilineDef = false def foo(bar: Bar): Foo = bar .flatMap(f) .map(g) // newlines.alwaysBeforeMultilineDef = true def foo(bar: Bar): Foo = bar .flatMap(f) .map(g)
If false (legacy behavior), inserts unconditional line break after yield
if the yield body doesn't fit on a single line.
For example,
// newlines.avoidAfterYield = true (default) for (a <- as) yield Future { ... } // newlines.avoidAfterYield = false (default before v2). for (a <- as) yield Future { ... }
Call-sites where there is a newline after opening ( and newline before closing ). If true, preserves the newlines and keeps one line per argument.
If true, then the user can opt out of line breaks inside select chains.
// original foo .map(_ + 1).map(_ + 1) .filter(_ > 2) // if true foo .map(_ + 1).map(_ + 1) .filter(_ > 2) // if false foo .map(_ + 1) .map(_ + 1) .filter(_ > 2)
If true, keeps the line break before a dot if it already exists.
// original foo .map(_ + 1) .filter( > 2) // if true foo .map(_ + 1) .filter( > 2) // if false foo.map(_ + 1).filter( > 2)
See https://github.com/scalameta/scalafmt/issues/938 If true, will force a line break before a self annotation if there was a line break there before.
If false, always insert a blank line before docstrings, If true, preserves blank line only if one exists before. Example:
// before object Foo { /** Docstring */ def foo = 2 } // after, if blankLineBeforeDocstring=true object Foo { /** Docstring */ def foo = 2 } // after, if blankLineBeforeDocstring=false object Foo { /** Docstring */ def foo = 2 }
Configuration options for scalafmt.
Configuration options for scalafmt.
The version of scalafmt to use for this project. Currently not used, the plan is to use this field for the IntelliJ+sbt integrations.
Column limit, any formatting exceeding this field is penalized heavily.
Several options:
If LineEndings.unix, output will include only unix line endings If LineEndings.windows, output will include only windows line endings If LineEndings.preserve, output will include endings included in original file (windows if there was at least one windows line ending, unix if there was zero occurrences of windows line endings)
Map of tokens to rewrite. For example, Map("⇒" -> "=>") will rewrite unicode arrows to regular ascii arrows.
If true, indents yield
by two spaces
for (i <- j)
yield banana
If false, treats yield
like else
for (i <- j)
yield banana
Controls formatting of import selectors with multiple names from the
same package;
If org.scalafmt.config.ImportSelectors.binPack, import selectors are
arranged to fit within the maximum line width
If org.scalafmt.config.ImportSelectors.noBinPack, import selectors
are broken to one per line
If org.scalafmt.config.ImportSelectors.singleLine, import selectors
are kept on a single line
The default setting is currently noBinPack
.
If true, allows no indentation on infix operators in non-top-level functions. For example, function( a && b ) If false, only allows 0 space indentation for top-level statements a && b function( a && b ) Context: https://github.com/scala-js/scala-js/blob/master/CODINGSTYLE.md#long-expressions-with-binary-operators
If true, includes curly brace applications in select chains/pipelines.
// If true List(1) .map { x => x + 2 } .filter(_ > 2) // If false List(1).map { x => x + 2 }.filter(_ > 2)
If true, includes applications without parens in select chains/pipelines.
// If true List(1) .toIterator .buffered .map(_ + 2) .filter(_ > 2) // If false List(1).toIterator.buffered .map(_ + 2) .filter(_ > 2)
If true, the margin character | is treated
as the new indentation in multiline strings
ending with .stripMargin
.
If true AND @binPackArguments is true AND @configStyleArguments is false, then this function( longerArg1, longerArg3) is formatted like this function( longerArg1, longerArg3 )
(experimental, may be removed) If true, formats config style like this: function( a , b , c )
If org.scalafmt.config.TrailingCommas.always, trailing commas are added everywhere a newline is followed by a right parens, brace or bracket. If org.scalafmt.config.TrailingCommas.never, trailing commas are removed whenever they appear. If org.scalafmt.config.TrailingCommas.preserve, existing trailing commas will be preserved, and no new ones will be added.
Configuration for scalafmt optimizations.
Configuration for scalafmt optimizations.
Clear the search queue on new statements.
Use heuristics to escape when the search state grows out of bounds. An optimization that trades off optimal formatting output in order to complete in a reasonable time. Used as a last resort.
Visit the same formatToken at most maxVisitsPerToken times.
How often do we try to escape before giving up and use original formatting.
Maximum depth of recursion.
Whether to listen to optimalAt fields in Splits.
Do not optimize inside certain areas such as term apply.
Eliminate solutions that move slower than other solutions. If a solution reaches a point X first and other solution that reaches the same point later, the first solution is preferred if it can be verified to be always better (see org.scalafmt.internal.State.alwaysBetter()). Note. This affects the output positively because it breaks a tie between two equally expensive solutions by eliminating the slower one. Example, solution 1 is preferred even though both solutions cost the same: // solution 1 a + b + c + d // solution 2 a + b + c + d
Recursively format { ... } blocks inside no optimization zones. By starting a new search queue, we can perform aggressive optimizations inside optimizations zones.
If negative number, does nothing. If n >= 0, then scalafmt will force "config style" on Term.Apply nodes IF it has more than forceConfigStyleMinArgCount arguments AND the non-whitespace byte offset between the opening parens and closing parens is greater than forceConfigStyleOnOffset. By forcing config style on such applications, the search space is greatly reduced.
A FormatRunner configures how formatting should behave.
A FormatRunner configures how formatting should behave.
Should we collect debugging statistics?
Listen to events that happens while formatting
Are we formatting a scala.meta.{Source,Stat,Case,...}? For more details, see members of scala.meta.parsers.
formats [A: T] as [A : T]
If true, formats ===( as === (
If true, formats import a.b.{ c, d }
.
If false, formats import a.b.{c, d}
.
If true, formats foo(a, b)
as foo( a, b )
.
If ["##"] is specified as operator then
formats Generic[Foo] ## Repr
as Generic[Foo]##Repr
.
if false, does not add a space between a keyword and a parenthesis. For example: if(a) println("HELLO!") while(a) println("HELLO!")
If false, removes space in by-name parameter.
def foo(a: =>A)
If true, adds a single space after an operator method For example: def <=> [T](that: T): Boolean
ADT representing trailing commas settings
ADT representing trailing commas settings
When org.scalafmt.config.TrailingCommas.always is selected, trailing commas are added everywhere a newline is followed by a right parens, brace or bracket.
When org.scalafmt.config.TrailingCommas.never is selected, trailing commas are removed whenever they appear.
When org.scalafmt.config.TrailingCommas.preserve is selected, existing trailing commas will be preserved, and no new ones will be added.
Configuration related to multi-line formatting.