-
Notifications
You must be signed in to change notification settings - Fork 43
/
.scalafmt.conf
168 lines (152 loc) · 4.68 KB
/
.scalafmt.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
version = "3.7.17"
runner.dialect = scala213
maxColumn = 300
// https://scalameta.org/scalafmt/docs/configuration.html#projectgit
project.git = true
fileOverride {
"glob:**/project/**.scala" {
runner.dialect = scala212
}
"glob:**/*.sbt" {
runner.dialect = sbt1
}
}
// ---------------------
// alignment
// ---------------------
align.preset = most
// align code behind -> e.g. in for ... yield
align.arrowEnumeratorGenerator = true
// multiline strings
align.stripMargin = true
assumeStandardLibraryStripMargin = true
// align also multiline statements
align.multiline = true
// don't break lines just because of alignment
align.allowOverflow = true
// align '='
align.tokens."+" = [
{
code = "="
owners = [{
parents = ["Template"]
}]
}
{
code = "="
owners = [{
regex = "Enumerator\\."
parents = ["Term\\.ForYield"]
}]
}
]
// align vals and types equally
align.treeCategory."Defn.Val" = "given/val/var/def"
align.treeCategory."Defn.Type" = "given/val/var/def"
// ---------------------
// indentation
// ---------------------
// identation of function calls
indent.callSite = 2
// indentation of "if" and "while"
indent.ctrlSite = 2
// identation of definition of parameters in cls and fce
indent.defnSite = 2
// indentation of "extends" and "with"
indent.extendSite = 2
// indent nested match and infix expressions
// this causes issues with // comments, indents them
// indent.relativeToLhsLastLine = [match, infix]
// indentation of multiline nested parentheses
binPack.indentCallSiteOnce = false
binPack.indentCallSiteSingleArg = false
// ---------------------
// indent operator
// ---------------------
// apply indentation exempts only in some cases
//indentOperator.preset = "spray"
// exempt indentation of 2nd and additional lines in special cases
indentOperator.exemptScope = all
// ---------------------
// new lines
// ---------------------
// remove line breaks, leads to horizontal code
//newlines.source = fold
// newlines around statements
newlines.topLevelStatementBlankLines = [
{
blanks = 1
}
{
minBreaks = 1
blanks = 1
}
]
// newlines after package, class, trait header if body is not trivial
newlines.topLevelBodyIfMinStatements = []
newlines.topLevelBodyMinStatements = 2
newlines.beforeTemplateBodyIfBreakInParentCtors = true
// force newline in case/if/while when the body is multiline
newlines.beforeMultiline = keep
newlines.alwaysBeforeElseAfterCurlyIf = false
// break when assignment is multiline
// newlines.forceBeforeMultilineAssign = any
// formatting of bounds of type parameters: upper <:, lower >:, view <%, and context : bounds
newlines.beforeTypeBounds = unfold
// newlines in { case ... => f() } lambdas
// newlines.beforeCurlyLambdaParams = never
// newlines.afterCurlyLambdaParams = squash
// spaces after implicit in fce parameter list
//newlines.implicitParamListModifierForce = [after]
//newlines.avoidForSimpleOverflow = [punct, tooLong, slc]
// skip newlines in the result type
newlines.avoidInResultType = true
// don't put newline before : of the result type if line overflows
newlines.sometimesBeforeColonInMethodReturnType = false
// chains of calls
newlines.selectChains = keep
// in interpolation
newlines.inInterpolation = avoid
// dangling parenteses
danglingParentheses.preset = true
danglingParentheses.exclude = []
// config style arguments
//optIn.configStyleArguments = true
//runner.optimizer.forceConfigStyleOnOffset = 80
//runner.optimizer.forceConfigStyleMinArgCount = 1
// rewrite rules
// - drop redundant braces like { } around a block
// - drop redundant parentheses like ( ) around a statement
// - sort implicit final private lazy
// - prefer for { } yield () over for (;) yield ()
// - organize imports
rewrite.rules = [RedundantBraces, RedundantParens, SortModifiers, PreferCurlyFors, Imports]
rewrite.redundantBraces.stringInterpolation = true
rewrite.imports.sort = scalastyle
rewrite.trailingCommas.style = always
// rewrite tokens to different characters
rewriteTokens = {
"⇒": "=>"
"→": "->"
"←": "<-"
}
// vertical align a line breaks
verticalMultiline.atDefnSite = true
verticalMultiline.arityThreshold = 100
verticalMultiline.newlineAfterOpenParen = true
// wrap long standalone comments
comments.wrap = standalone
comments.wrapStandaloneSlcAsSlc = true
// javadoc formatting
docstrings.style = SpaceAsterisk
docstrings.blankFirstLine = yes
docstrings.removeEmpty = true
docstrings.oneline = fold
docstrings.wrapMaxColumn = 80
// all calls in chains start on a new line
includeNoParensInSelectChains = true
// keep chains on multiple lines if already multiline
optIn.breakChainOnFirstMethodDot = true
// scala 3 config
rewrite.scala3.convertToNewSyntax = true
//rewrite.trailingCommas.style = "multiple"