1616# limitations under the License.
1717#
1818
19- # See https://scalameta.org/scalafmt/docs/configuration.html for details,
20- # mostly done by trial and error. But I guess this formatting is "good enough"
19+ # See https://scalameta.org/scalafmt/docs/configuration.html for details
2120#
21+ # https://github.com/scalameta/scalafmt/releases
22+ version = 3.0 .0 -RC6
2223
23- # https://github.com/scalameta/scalafmt/releases
24- version = 2.7 .5
25-
26- project {
27- # if you don't specify that files ending in .scala .sbt with $,
28- # .scalafmt.conf is included in the formatting attempt
29- includeFilters = [
30- ".*.\\ .scala$"
31- ".*\\ ..sbt$"
32- ]
24+ fileOverride {
25+ "glob:**/src/main/scala/**" {
26+ runner.dialect = scala213source3
27+ }
28+ "glob:**/src/test/scala/**" {
29+ runner.dialect = scala213source3
30+ }
31+ "glob:**/src/main/scala-2/**" {
32+ runner.dialect = scala213source3
33+ }
34+ "glob:**/src/test/scala-2/**" {
35+ runner.dialect = scala213source3
36+ }
37+ "glob:**/src/main/scala-3/**" {
38+ runner.dialect = scala3
39+ }
40+ "glob:**/src/test/scala-3/**" {
41+ runner.dialect = scala3
42+ }
43+ "glob:**/project/*.scala" {
44+ runner.dialect = scala212
45+ }
46+ "glob:**/*.sbt" {
47+ runner.dialect = Sbt1
48+ }
3349}
3450
3551maxColumn = 120
3652
37- # Note. Only for the truest vertical aligners. This is a new option,
38- # feel free to open PR enabling more crazy vertical alignment here.
39- # Expect changes.
4053align = most
4154align.openParenCallSite = false
4255align.openParenDefnSite = false
4356align.multiline = true
57+ align.tokens."+" = [
4458
45- align.tokens.add = [
46-
47- {code = "<-" , owner = "Enumerator.Generator" }
48- // Everything before the Term.Assign was the default regex. To find the
49- // default value, look through the code here:
50- // https://github.com/scalameta/scalafmt/blob/master/scalafmt-core/shared/src/main/scala/org/scalafmt/config/Align.scala
51- {code = "=" , owner = "(Enumerator.Generator|Val|Defn.(Va(l|r)|Def|Type))|Term.Assign" }
59+ {code = "<-" , owner = "Enumerator.Generator" },
5260
53- // used to align comments
54- "//"
61+ # Everything before the Term.Assign was the default regex. To find the
62+ # default value, look through the code here:
63+ # https://github.com/scalameta/scalafmt/blob/master/scalafmt-core/shared/src/main/scala/org/scalafmt/config/Align.scala
64+ {code = "=" , owner = "(Enumerator.Generator|Val|Defn.(Va(l|r)|Def|Type))|Term.Assign|Param" },
5565
56- // used for aligning type definition
57- ":"
58-
59- // used when creating tuples
60- {code = "->" , owner = "Term.ApplyInfix" },
66+ "//" , # used to align comments
67+ ":" , # used for aligning type definition
68+ {code = "->" , owner = "Term.ApplyInfix" }, # used to align tuples 1 -> 2
6169
6270 // sbt specific
6371 {code = "%" , owner = "Term.ApplyInfix" },
64- {code = "%%" , owner = "Term.ApplyInfix" }
65- {code = "%%%" , owner = "Term.ApplyInfix" }
66- {code = ":=" , owner = "Term.ApplyInfix" }
67- {code = "withSources" , owner = "Term.ApplyInfix" }
72+ {code = "%%" , owner = "Term.ApplyInfix" },
73+ {code = "%%%" , owner = "Term.ApplyInfix" },
74+ {code = ":=" , owner = "Term.ApplyInfix" },
75+ {code = "withSources" , owner = "Term.ApplyInfix" },
6876 "extends"
6977]
7078
79+ # ##############################################################################
80+
7181continuationIndent {
7282 callSite = 2
7383 defnSite = 2
@@ -76,12 +86,16 @@ continuationIndent {
7686 withSiteRelativeToExtends = 0
7787}
7888
89+ # ##############################################################################
90+
7991verticalMultiline.atDefnSite = false
8092verticalMultiline.newlineAfterOpenParen = true
8193verticalMultiline.arityThreshold = 3
8294
95+ # ##############################################################################
96+
8397newlines {
84- alwaysBeforeTopLevelStatements = true
98+ topLevelStatements = [ before ]
8599 sometimesBeforeColonInMethodReturnType = true
86100 penalizeSingleSelectMultiArgList = false
87101 alwaysBeforeElseAfterCurlyIf = true
@@ -91,30 +105,35 @@ newlines {
91105 afterCurlyLambda = squash
92106}
93107
108+ # ##############################################################################
109+
94110spaces {
95111 afterKeywordBeforeParen = true
96112}
97113
114+ # ##############################################################################
115+
98116binPack {
99117 parentConstructors = true
100118 literalArgumentLists = true
101119 literalsMinArgCount = 5
102120}
103121
122+ # ##############################################################################
104123
105124optIn {
106125 breaksInsideChains = false
107- // preserves existing newlines in . chain calls.
108- // See: optIn.breakChainOnFirstMethodDot = true
126+ # preserves existing newlines in . chain calls.
127+ # See: optIn.breakChainOnFirstMethodDot = true
109128 breakChainOnFirstMethodDot = true
110129 blankLineBeforeDocstring = true
111130}
112131
132+ # ##############################################################################
133+
113134rewrite {
114135 rules = [
115- SortImports
116136 SortModifiers
117- # if your for has more than one single <- then it gets transformed into a multit-line curly brace one
118137 PreferCurlyFors
119138 AvoidInfix
120139 RedundantBraces
@@ -127,40 +146,21 @@ rewrite.redundantBraces.methodBodies = true
127146rewrite.redundantBraces.includeUnitMethods = false
128147rewrite.redundantBraces.stringInterpolation = true
129148rewrite.redundantBraces.parensForOneLineApply = true
149+ rewrite.neverInfix.excludeFilters = [withSources ]
130150
131- # we only really want to disable infix notation
132- # for map and flatMap and the like, because it
133- # kills IDE performance and type inference
134- rewrite.neverInfix.excludeFilters = [
135- until
136- to
137- by
138- eq
139- ne
140- "should.*"
141- "contain.*"
142- "must.*"
143- in
144- be
145- of # behaviour of ("X")
146- taggedAs
147- thrownBy
148- synchronized
149- have
150- when
151- size
152- theSameElementsAs
153- withSources
154- ]
151+ # ##############################################################################
155152
156153preset = default
157154danglingParentheses.preset = true
158155
156+ # ##############################################################################
157+
159158assumeStandardLibraryStripMargin = true
160159includeNoParensInSelectChains = false
161160includeCurlyBraceInSelectChains = true
162161trailingCommas = multiple
163162
163+ # ##############################################################################
164164
165165runner {
166166 optimizer {
@@ -171,4 +171,4 @@ runner {
171171 # minimum number of func arguments before config-style (look at top of file) is enabled
172172 forceConfigStyleMinArgCount = 2
173173 }
174- }
174+ }
0 commit comments