Package

org.scalafmt

config

Permalink

package config

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. config
  2. ScalafmtConfDecoders
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. 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] = ...) extends Product with Serializable

    Permalink

    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.productPrefix align. 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.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.

  2. case class AlignToken(code: String, owner: String) extends Product with Serializable

    Permalink

    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.

  3. case class BaseStyle(style: ScalafmtConfig) extends Product with Serializable

    Permalink
  4. 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

    Permalink

    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.

  5. sealed abstract class Case extends AnyRef

    Permalink
  6. case class ContinuationIndent(callSite: Int = 2, defnSite: Int = 4, extendSite: Int = 4) extends Product with Serializable

    Permalink

    callSite

    indentation around function calls, etc.

    defnSite

    indentation around class/def

    extendSite

    indentation before extends

  7. sealed abstract class DanglingExclude extends AnyRef

    Permalink
  8. case class DanglingParentheses(callSite: Boolean, defnSite: Boolean) extends Product with Serializable

    Permalink
  9. sealed abstract class Docstrings extends AnyRef

    Permalink
  10. case class FilterMatcher(include: Regex, exclude: Regex) extends Product with Serializable

    Permalink
  11. abstract class FormatEvent extends AnyRef

    Permalink

    An event that happens while formatting a file.

  12. sealed abstract class ImportSelectors extends AnyRef

    Permalink

    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}
  13. case class IndentOperator(include: String = ".*", exclude: String = "^(&&|\\|\\|)$") extends Product with Serializable

    Permalink

    include

    Regexp for which infix operators should indent by 2 spaces. For example, .*= produces this output a && b a += b

    exclude

    Regexp for which infix operators should not indent by 2 spaces. For example, when include is .* and exclude is && a && b a || b a += b

  14. sealed abstract class LineEndings extends AnyRef

    Permalink
  15. case class Literals(long: Case = Case.Upper, float: Case = Case.Lower, double: Case = Case.Lower) extends Product with Serializable

    Permalink
  16. type MetaParser = Parse[_ <: Tree]

    Permalink
  17. sealed abstract class NewlineCurlyLambda extends AnyRef

    Permalink
  18. 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

    Permalink

    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 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.

    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 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 {
        ...
      }
  19. 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

    Permalink

    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
    }
  20. case class Pattern(includeFilters: Seq[String], excludeFilters: Seq[String]) extends Product with Serializable

    Permalink
  21. case class ProjectFiles(git: Boolean = false, files: Seq[String] = Nil, includeFilters: Seq[String] = ..., excludeFilters: Seq[String] = Nil) extends Product with Serializable

    Permalink
  22. case class RedundantBracesSettings(methodBodies: Boolean = true, includeUnitMethods: Boolean = true, maxLines: Int = 100, stringInterpolation: Boolean = false, generalExpressions: Boolean = false) extends Product with Serializable

    Permalink
  23. case class RewriteSettings(rules: Seq[Rewrite] = Nil, redundantBraces: RedundantBracesSettings = RedundantBracesSettings(), sortModifiers: SortSettings = SortSettings.default, neverInfix: Pattern = Pattern.neverInfix) extends Product with Serializable

    Permalink
  24. trait ScalafmtConfDecoders extends AnyRef

    Permalink
  25. 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

    Permalink

    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 yield by two spaces for (i <- j) yield banana If false, treats yield like else for (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.

  26. 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

    Permalink

    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.

  27. case class ScalafmtRunner(debug: Boolean = false, eventCallback: (FormatEvent) ⇒ Unit = _ => 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

    Permalink

    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.

  28. case class SortSettings(order: List[ModKey]) extends Product with Serializable

    Permalink
  29. sealed trait SpaceBeforeContextBound extends AnyRef

    Permalink
  30. 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

    Permalink

    beforeContextBoundColon

    formats [A: T] as [A : T]

    afterTripleEquals

    If true, formats ===( as === (

    inImportCurlyBraces

    If true, formats import a.b.{ c, d }. If false, formats import a.b.{c, d}.

    inParentheses

    If true, formats foo(a, b) as foo( a, b ).

    neverAroundInfixTypes

    If ["##"] is specified as operator then formats Generic[Foo] ## Repr as Generic[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

  31. sealed abstract class TrailingCommas extends AnyRef

    Permalink

    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.

  32. case class VerticalMultiline(atDefnSite: Boolean = false, arityThreshold: Int = 100, newlineBeforeImplicitKW: Boolean = false, newlineAfterImplicitKW: Boolean = false, newlineAfterOpenParen: Boolean = false, excludeDanglingParens: List[DanglingExclude] = ...) extends Product with Serializable

    Permalink

    Configuration related to multi-line formatting.

Value Members

  1. object Align extends Serializable

    Permalink
  2. object AlignToken extends Serializable

    Permalink
  3. object BaseStyle extends Serializable

    Permalink
  4. object BinPack extends Serializable

    Permalink
  5. object Case

    Permalink
  6. object Config

    Permalink
  7. object ContinuationIndent extends Serializable

    Permalink
  8. object DanglingExclude

    Permalink
  9. object DanglingParentheses extends Serializable

    Permalink
  10. object Docstrings

    Permalink
  11. object FilterMatcher extends Serializable

    Permalink
  12. object FormatEvent

    Permalink
  13. object ImportSelectors

    Permalink
  14. object IndentOperator extends Serializable

    Permalink
  15. object LineEndings

    Permalink
  16. object Literals extends Serializable

    Permalink
  17. object NewlineCurlyLambda

    Permalink
  18. object Newlines extends Serializable

    Permalink
  19. object OptIn extends Serializable

    Permalink
  20. object Pattern extends Serializable

    Permalink
  21. object PlatformConfig

    Permalink
  22. object ProjectFiles extends Serializable

    Permalink
  23. object ReaderUtil

    Permalink
  24. object RedundantBracesSettings extends Serializable

    Permalink
  25. object RewriteSettings extends Serializable

    Permalink
  26. object ScalafmtConfDecoders extends ScalafmtConfDecoders

    Permalink
  27. object ScalafmtConfig extends Serializable

    Permalink
  28. object ScalafmtOptimizer extends Serializable

    Permalink
  29. object ScalafmtRunner extends Serializable

    Permalink
  30. object SortSettings extends Serializable

    Permalink
  31. object SpaceBeforeContextBound

    Permalink
  32. object Spaces extends Serializable

    Permalink
  33. object TrailingCommas

    Permalink
  34. object VerticalMultiline extends Serializable

    Permalink
  35. implicit lazy val codecReader: ConfDecoder[Codec]

    Permalink
    Definition Classes
    ScalafmtConfDecoders
  36. implicit lazy val dialectReader: ConfDecoder[Dialect]

    Permalink
    Definition Classes
    ScalafmtConfDecoders
  37. implicit lazy val eventReader: ConfDecoder[(FormatEvent) ⇒ Unit]

    Permalink
    Definition Classes
    ScalafmtConfDecoders
  38. implicit lazy val parseReader: ConfDecoder[MetaParser]

    Permalink
    Definition Classes
    ScalafmtConfDecoders

Inherited from ScalafmtConfDecoders

Inherited from AnyRef

Inherited from Any

Ungrouped