Skip to content

Instantly share code, notes, and snippets.

@tvoklov
Last active May 22, 2024 11:42
Show Gist options
  • Save tvoklov/534bdaccc293158376c4624b6a36a59e to your computer and use it in GitHub Desktop.
Save tvoklov/534bdaccc293158376c4624b6a36a59e to your computer and use it in GitHub Desktop.
scala 3 scalafmt
// this is a very highly opinionated scalafmt file that aligns with
// what I view as most easily readable code style
// the point of this file is not to just make formatting more consistent,
// but enforce that consistency throughout the entire project
// works well with ci/cd actions that do a scalafmt check
// annoy your developers with linters until they break and adopt your code style!
version = 3.8.1
runner.dialect = scala3
align {
preset = more
multiline = true
}
maxColumn = 80
assumeStandardLibraryStripMargin = true
indent {
withSiteRelativeToExtends = 2
relativeToLhsLastLine = [match, infix]
}
newlines {
source = unfold
topLevelStatementBlankLines = [
{
blanks = 1
}
]
beforeMultiline = unfold
forceBeforeMultilineAssign = any
beforeCurlyLambdaParams = multilineWithCaseOnly
implicitParamListModifierForce = [before, after]
avoidForSimpleOverflow = [slc, punct]
afterCurlyLambdaParams = squash
}
danglingParentheses {
defnSite = true
callSite = true
ctrlSite = true
tupleSite = true
}
rewrite {
rules = [RedundantBraces, RedundantParens, SortModifiers, PreferCurlyFors, Imports]
redundantBraces {
stringInterpolation = true
defnBodies = "noParams"
maxBreaks = 3
}
sortModifiers.preset = styleGuide
imports {
sort = scalastyle
groups = [
["cats\\..*"],
["^(?!scala|java|volk|cats).*"],
["^(?=scala|java).*"],
["volk\\..*"],
]
}
scala3 {
convertToNewSyntax = true
}
trailingCommas {
style = multiple
}
}
comments.wrap = standalone
docstrings {
style = SpaceAsterisk
removeEmpty = true
oneline = fold
blankFirstLine = no
}
spaces {
beforeContextBoundColon = Always
inImportCurlyBraces = true
afterSymbolicDefs = true
beforeApplyArgInParens = AfterSymbolic
beforeInfixArgInParens = AfterSymbolic
}
importSelectors = singleLine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment