package config
- Alphabetic
- By Inheritance
- config
- ScalafmtConfDecoders
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- case class Align(openParenCallSite: Boolean = false, openParenDefnSite: Boolean = false, tokens: Set[AlignToken] = Set(AlignToken.caseArrow), arrowEnumeratorGenerator: Boolean = false, ifWhileOpenParen: Boolean = true, tokenCategory: Map[String, String] = Map(), treeCategory: Map[String, String] = Map(
"Defn.Val" -> "val/var/def",
"Defn.Var" -> "val/var/def",
"Defn.Def" -> "val/var/def",
"Defn.Class" -> "class/object/trait",
"Defn.Object" -> "class/object/trait",
"Defn.Trait" -> "class/object/trait",
"Enumerator.Generator" -> "for",
"Enumerator.Val" -> "for"
)) extends Product with Serializable
- openParenCallSite
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)
- openParenDefnSite
Same as openParenCallSite, except definition site.
- tokens
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.
- arrowEnumeratorGenerator
If true, aligns by <- in for comprehensions.
- ifWhileOpenParen
If true, aligns by ( in if/while/for. If false, indents by continuation indent at call site.
- tokenCategory
Customize which token kinds can align together. By default, only tokens with the same
Token.productPrefixalign. To for example align = and <-, set the values to: Map("Equals" -> "Assign", "LeftArrow" -> "Assign") Note. Requires mixedTokens to be true.- treeCategory
Customize which tree kinds can align together. By default, only trees with the same
Tree.productPrefixalign. 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.
- case class AlignToken(code: String, owner: String) extends Product with Serializable
Configuration option for aligning tokens.
Configuration option for aligning tokens.
- code
string literal value of the token to align by.
- owner
regexp for class name of scala.meta.Tree "owner" of code.
- case class BaseStyle(style: ScalafmtConfig) extends Product with Serializable
- case class BinPack(unsafeCallSite: Boolean = false, unsafeDefnSite: Boolean = false, parentConstructors: Boolean = false, literalArgumentLists: Boolean = true, literalsMinArgCount: Int = 5, literalsInclude: Seq[String] = Seq(".*"), literalsExclude: Seq[String] = Seq("String", "Term.Name")) extends Product with Serializable
- unsafeCallSite
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.
- unsafeDefnSite
Same as unsafeCallSite, except for definition site.
- parentConstructors
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.
- literalArgumentLists
If true, automatically sets the style to bin-pack for argument lists that only consist of literals.
- literalsMinArgCount
Argument list must be longer than this setting to be eligible for literalArgumentLists.
- literalsInclude
Regexes for literal type names. For example, "Int" or "Byte".
- literalsExclude
Regexes for literal to exclude from literalArgumentLists.
- sealed abstract class Case extends AnyRef
- case class ContinuationIndent(callSite: Int = 2, defnSite: Int = 4, extendSite: Int = 4) extends Product with Serializable
- callSite
indentation around function calls, etc.
- defnSite
indentation around class/def
- extendSite
indentation before
extends
- sealed abstract class DanglingExclude extends AnyRef
- case class DanglingParentheses(callSite: Boolean, defnSite: Boolean) extends Product with Serializable
- sealed abstract class Docstrings extends AnyRef
- case class FilterMatcher(include: Regex, exclude: Regex) extends Product with Serializable
- abstract class FormatEvent extends AnyRef
An event that happens while formatting a file.
- sealed abstract class ImportSelectors extends AnyRef
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}
- case class IndentOperator(include: String = ".*", exclude: String = "^(&&|\\|\\|)$") extends Product with Serializable
- sealed abstract class LineEndings extends AnyRef
- case class Literals(long: Case = Case.Upper, float: Case = Case.Lower, double: Case = Case.Lower) extends Product with Serializable
- type MetaParser = Parse[_ <: Tree]
- sealed abstract class NewlineCurlyLambda extends AnyRef
- case class Newlines(neverInResultType: Boolean = false, neverBeforeJsNative: Boolean = false, sometimesBeforeColonInMethodReturnType: Boolean = true, penalizeSingleSelectMultiArgList: Boolean = true, alwaysBeforeCurlyBraceLambdaParams: Boolean = false, alwaysBeforeTopLevelStatements: Boolean = false, afterCurlyLambda: NewlineCurlyLambda = NewlineCurlyLambda.never, afterImplicitKWInVerticalMultiline: Boolean = false, beforeImplicitKWInVerticalMultiline: Boolean = false, alwaysBeforeElseAfterCurlyIf: Boolean = false, alwaysBeforeMultilineDef: Boolean = true, avoidAfterYield: Boolean = true) extends Product with Serializable
- neverBeforeJsNative
If true, a newline will never be placed in front of js.native.
- sometimesBeforeColonInMethodReturnType
If true, scalafmt may choose to put a newline before colon : at defs.
- penalizeSingleSelectMultiArgList
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.
- alwaysBeforeCurlyBraceLambdaParams
If true, puts a newline after the open brace and the parameters list of an anonymous function. For example something.map { n => consume(n) }
- afterCurlyLambda
If
never(default), it will remove any extra lines below curly lambdassomething.map { x => f(x) }will become
something.map { x => f(x) }If
always, it will always add one empty line (opposite ofnever). Ifpreserve, 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.- alwaysBeforeElseAfterCurlyIf
if true, add a new line between the end of a curly if and the following else. For example if(someCond) { // ... } else //...
- alwaysBeforeMultilineDef
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)
- avoidAfterYield
If false (legacy behavior), inserts unconditional line break after
yieldif 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 { ... }
- case class OptIn(configStyleArguments: Boolean = true, breaksInsideChains: Boolean = false, breakChainOnFirstMethodDot: Boolean = true, selfAnnotationNewline: Boolean = true, annotationNewlines: Boolean = true, blankLineBeforeDocstring: Boolean = false) extends Product with Serializable
- configStyleArguments
Call-sites where there is a newline after opening ( and newline before closing ). If true, preserves the newlines and keeps one line per argument.
- breaksInsideChains
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)
- breakChainOnFirstMethodDot
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)
- selfAnnotationNewline
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.
- blankLineBeforeDocstring
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 }
- case class Pattern(includeFilters: Seq[String], excludeFilters: Seq[String]) extends Product with Serializable
- case class ProjectFiles(git: Boolean = false, files: Seq[String] = Nil, includeFilters: Seq[String] = Seq(".*\\.scala$", ".*\\.sbt$", ".*\\.sc$"), excludeFilters: Seq[String] = Nil) extends Product with Serializable
- case class RedundantBracesSettings(methodBodies: Boolean = true, includeUnitMethods: Boolean = true, maxLines: Int = 100, stringInterpolation: Boolean = false, generalExpressions: Boolean = false) extends Product with Serializable
- case class RewriteSettings(rules: Seq[Rewrite] = Nil, redundantBraces: RedundantBracesSettings = RedundantBracesSettings(), sortModifiers: SortSettings = SortSettings.default, neverInfix: Pattern = Pattern.neverInfix) extends Product with Serializable
- trait ScalafmtConfDecoders extends AnyRef
- case class ScalafmtConfig(version: String = org.scalafmt.Versions.stable, maxColumn: Int = 80, docstrings: Docstrings = Docstrings.ScalaDoc, optIn: OptIn = OptIn(), binPack: BinPack = BinPack(), continuationIndent: ContinuationIndent = ContinuationIndent(), align: Align = Align(), spaces: Spaces = Spaces(), literals: Literals = Literals(), lineEndings: LineEndings = LineEndings.unix, rewriteTokens: Map[String, String] = Map.empty[String, String], rewrite: RewriteSettings = RewriteSettings(), indentOperator: IndentOperator = IndentOperator(), newlines: Newlines = Newlines(), runner: ScalafmtRunner = ScalafmtRunner.default, indentYieldKeyword: Boolean = true, importSelectors: ImportSelectors = ImportSelectors.noBinPack, unindentTopLevelOperators: Boolean = false, includeCurlyBraceInSelectChains: Boolean = true, includeNoParensInSelectChains: Boolean = false, assumeStandardLibraryStripMargin: Boolean = false, danglingParentheses: DanglingParentheses = DanglingParentheses(true, true), poorMansTrailingCommasInConfigStyle: Boolean = false, trailingCommas: TrailingCommas = TrailingCommas.never, verticalMultilineAtDefinitionSite: Boolean = false, verticalMultilineAtDefinitionSiteArityThreshold: Int = 100, verticalMultiline: VerticalMultiline = VerticalMultiline(), verticalAlignMultilineOperators: Boolean = false, onTestFailure: String = "", encoding: Codec = "UTF-8", project: ProjectFiles = ProjectFiles()) extends Product with Serializable
Configuration options for scalafmt.
Configuration options for scalafmt.
- version
The version of scalafmt to use for this project. Currently not used, the plan is to use this field for the IntelliJ+sbt integrations.
- maxColumn
Column limit, any formatting exceeding this field is penalized heavily.
- docstrings
Several options:
- ScalaDoc: format as Scala docs
- JavaDocs: format as Java docs
- preserve: keep existing formatting
- lineEndings
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)
- rewriteTokens
Map of tokens to rewrite. For example, Map("⇒" -> "=>") will rewrite unicode arrows to regular ascii arrows.
- indentYieldKeyword
If true, indents
yieldby two spaces for (i <- j) yield banana If false, treatsyieldlikeelsefor (i <- j) yield banana- importSelectors
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.- unindentTopLevelOperators
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
- includeCurlyBraceInSelectChains
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)
- includeNoParensInSelectChains
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)
- assumeStandardLibraryStripMargin
If true, the margin character | is treated as the new indentation in multiline strings ending with
.stripMargin.- danglingParentheses
If true AND @binPackArguments is true AND @configStyleArguments is false, then this function( longerArg1, longerArg3) is formatted like this function( longerArg1, longerArg3 )
- poorMansTrailingCommasInConfigStyle
(experimental, may be removed) If true, formats config style like this: function( a , b , c )
- trailingCommas
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.
- case class ScalafmtOptimizer(dequeueOnNewStatements: Boolean = true, escapeInPathologicalCases: Boolean = true, maxVisitsPerToken: Int = 513, maxEscapes: Int = 16, maxDepth: Int = 100, acceptOptimalAtHints: Boolean = true, disableOptimizationsInsideSensitiveAreas: Boolean = true, pruneSlowStates: Boolean = true, recurseOnBlocks: Boolean = true, forceConfigStyleOnOffset: Int = 150, forceConfigStyleMinArgCount: Int = 2) extends Product with Serializable
Configuration for scalafmt optimizations.
Configuration for scalafmt optimizations.
- dequeueOnNewStatements
Clear the search queue on new statements.
- escapeInPathologicalCases
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.
- maxVisitsPerToken
Visit the same formatToken at most maxVisitsPerToken times.
- maxEscapes
How often do we try to escape before giving up and use original formatting.
- maxDepth
Maximum depth of recursion.
- acceptOptimalAtHints
Whether to listen to optimalAt fields in Splits.
- disableOptimizationsInsideSensitiveAreas
Do not optimize inside certain areas such as term apply.
- pruneSlowStates
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
- recurseOnBlocks
Recursively format { ... } blocks inside no optimization zones. By starting a new search queue, we can perform aggressive optimizations inside optimizations zones.
- forceConfigStyleOnOffset
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.
- case class ScalafmtRunner(debug: Boolean = false, eventCallback: (FormatEvent) => Unit = _ => (), parser: Parse[_ <: Tree] = Parse.parseSource, optimizer: ScalafmtOptimizer = ScalafmtOptimizer.default, maxStateVisits: Int = 1000000, dialect: Dialect = ScalafmtRunner.defaultDialect, ignoreWarnings: Boolean = false, fatalWarnings: Boolean = false) extends Product with Serializable
A FormatRunner configures how formatting should behave.
A FormatRunner configures how formatting should behave.
- debug
Should we collect debugging statistics?
- eventCallback
Listen to events that happens while formatting
- parser
Are we formatting a scala.meta.{Source,Stat,Case,...}? For more details, see members of scala.meta.parsers.
- case class SortSettings(order: List[ModKey]) extends Product with Serializable
- sealed trait SpaceBeforeContextBound extends AnyRef
- case class Spaces(beforeContextBoundColon: SpaceBeforeContextBound = Never, afterTripleEquals: Boolean = false, inImportCurlyBraces: Boolean = false, inParentheses: Boolean = false, neverAroundInfixTypes: Seq[String] = Nil, afterKeywordBeforeParen: Boolean = true, inByNameTypes: Boolean = true, afterSymbolicDefs: Boolean = false) extends Product with Serializable
- beforeContextBoundColon
formats [A: T] as [A : T]
- afterTripleEquals
If true, formats ===( as === (
- inImportCurlyBraces
If true, formats
import a.b.{ c, d }. If false, formatsimport a.b.{c, d}.- inParentheses
If true, formats
foo(a, b)asfoo( a, b ).- neverAroundInfixTypes
If ["##"] is specified as operator then formats
Generic[Foo] ## ReprasGeneric[Foo]##Repr.- afterKeywordBeforeParen
if false, does not add a space between a keyword and a parenthesis. For example: if(a) println("HELLO!") while(a) println("HELLO!")
- inByNameTypes
If false, removes space in by-name parameter.
def foo(a: =>A)- afterSymbolicDefs
If true, adds a single space after an operator method For example: def <=> [T](that: T): Boolean
- sealed abstract class TrailingCommas extends AnyRef
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.
- case class VerticalMultiline(atDefnSite: Boolean = false, arityThreshold: Int = 100, newlineBeforeImplicitKW: Boolean = false, newlineAfterImplicitKW: Boolean = false, newlineAfterOpenParen: Boolean = false, excludeDanglingParens: List[DanglingExclude] = List(
DanglingExclude.`class`,
DanglingExclude.`trait`
)) extends Product with Serializable
Configuration related to multi-line formatting.
Value Members
- implicit lazy val codecReader: ConfDecoder[Codec]
- Definition Classes
- ScalafmtConfDecoders
- implicit lazy val dialectReader: ConfDecoder[Dialect]
- Definition Classes
- ScalafmtConfDecoders
- implicit lazy val eventReader: ConfDecoder[(FormatEvent) => Unit]
- Definition Classes
- ScalafmtConfDecoders
- implicit lazy val parseReader: ConfDecoder[MetaParser]
- Definition Classes
- ScalafmtConfDecoders
- object Align extends Serializable
- object AlignToken extends Serializable
- object BaseStyle extends Serializable
- object BinPack extends Serializable
- object Case
- object Config
- object ContinuationIndent extends Serializable
- object DanglingExclude
- object DanglingParentheses extends Serializable
- object Docstrings
- object FilterMatcher extends Serializable
- object FormatEvent
- object ImportSelectors
- object IndentOperator extends Serializable
- object LineEndings
- object Literals extends Serializable
- object NewlineCurlyLambda
- object Newlines extends Serializable
- object OptIn extends Serializable
- object Pattern extends Serializable
- object PlatformConfig
- object ProjectFiles extends Serializable
- object ReaderUtil
- object RedundantBracesSettings extends Serializable
- object RewriteSettings extends Serializable
- object ScalafmtConfDecoders extends ScalafmtConfDecoders
- object ScalafmtConfig extends Serializable
- object ScalafmtOptimizer extends Serializable
- object ScalafmtRunner extends Serializable
- object SortSettings extends Serializable
- object SpaceBeforeContextBound
- object Spaces extends Serializable
- object TrailingCommas
- object VerticalMultiline extends Serializable