0.21
New formatting mode: --kotlinlang-style
Usage: ktfmt --kotlinlang-style File.kt …`
Example:
fun throwParseError(fileContents: String, error: PsiErrorElement): Nothing {
throw ParseError(
error.errorDescription,
StringUtil.offsetToLineColumn(fileContents, error.startOffset)
)
}
- This new style is more similar to the official Kotlin conventions at https://kotlinlang.org/docs/coding-conventions.html.
In particular,- Continuation + Block indents of 4.
- Closing parenthesis of call expressions are on a new line.
- However, we don't claim it adheres to the conventions 100%.
- Unlike
--dropbox-style
, this new style was tested and scrutinized. We recommend migrating off of Dropbox style as it is unmaintained and untested.
As usual, please let us know of any issues.
Other fixes
- New lines between top-level elements: at most one newline between any two classes/functions/…, and at least one newline (excluding properties). Thanks @xiphirx !
We haven't integrated --kotlinlang-style
with the IntelliJ plugin yet.