All notable changes to the ktfmt project (starting on v0.51) should be documented in this file.
The format is based on Keep a Changelog.
- Support partial formatting with
--lines/--lineand matching--offset/--lengthpairs, mirroring google-java-format's selected-range formatting flags. - Support selected-range formatting in the IntelliJ plugin.
- Reduced overall number of allocations to improve formatting performance (~6-7%) (#620)
- Reuse results of
Parser.parse(#622)
- Support name-based destructuring declarations. (#629)
- Support
ij_kotlin_indent_sizein editorconfig. (#604) - Support for lists within quoted blocks in KDoc comments (https://github.com/facebook/ktfmt/commit/68fa1585b759ad4b12ca4802bccd297f6a33b0f3)
- Fix
ONLY_ADDtrailing commas strategy causing lines over MAX_WIDTH length (#610) - Remove forced breaking of
contextfunction types (#613) - Preserve user-authored line breaks inside lambda bodies by default, rather than have ktfmt impose anything. This can be particularly useful for DSL syntax like Compose UI or Kotlin Gradle script. The behavior follows the
FormattingOptions.preserveLambdaBreakssetting of the chosen style. (#614) - Add a
FormattingOptions.BuilderAPI for tools to avoid breaking ABI changes with new options. (#614)
- Support
ij_kotlin_continuation_indent_sizein editorconfig. (#600) - Add
--quietflag to suppress per-file formatting status output. (#558)
- Compatibility with Kotlin compiler v2.3.20 (
CONTEXT_RECEIVER_LISTrenamed toCONTEXT_PARAMETER_LIST, K1 API opt-in forKotlinCoreEnvironment.createForProduction) (#605) - Dot-qualified scoping functions (e.g.,
scope.launch { }) now format as block-like expressions, consistent with non-qualified calls (GH#205) - Backtick-escaped full-path imports are no longer incorrectly removed as unused (#532)
- Single-line comments in if expressions are now correctly indented (#591)
- Idea Plugin not applying custom trailing commas management strategy (#593)
- Comments between a multiline string and
.trimMargin()/.trimIndent()are no longer deleted during formatting (#597) - Blank lines before lists and blockquotes in KDoc comments are now preserved (#561)
maxCommentWidthnow defaults tomaxLineWidthinstead of being capped at 72, so KDoc comments respect the configured line width (#594)- Block comment formatting inside of lambda expressions (#602)
- Fenced code blocks inside KDoc list items are no longer erroneously reflowed into a single line (#572)
- Comments before
&&/||operators in chained binary expressions no longer strand the operator on its own line (#527) - Lambda bodies in
whenbranches no longer get extra indentation with Meta style (#222)
- Support for Kotlin 2.3.0 explicit backing field (#580)
- Editorconfig not found for relative paths (#582)
- Support for
else ifguard conditions (#563) - Explicit Kotlin import layout for the default and Google specific editorconfig files to match ktfmt's style. The same layout was already applied to the Kotlin Lang editorconfig (#571)
- ktfmt cli can pull formatting configs from editor config files (#570)
- Strip leading UTF-8 BOM before formatting so ktfmt no longer errors on files starting with a BOM (#565)
- Special format handling of multiline strings handling of first line and do not format string template expressions
- Do not remove semicolon after an unnamed empty companion object, if it isn't the last element (#557)
- Updated ShadowJar to 9.0.2 (#555)
- Do not apply special format handling of multiline strings with template expressions in them (#556)
- Make sure that we handle nested expressions for special format handling of multiline strings
TrailingCommaManagementStrategy.ONLY_ADDstrategy that does not remove existing trailing commas (#461, #512, #514)- Formatting of where clauses (#541)
- Special format handling of multiline strings with
trimMargin()andtrimIndent()(#389)
FormattingOptions.manageTrailingCommaswas replaced withFormattingOptions.trailingCommaManagementStrategy, which also added newTrailingCommaManagementStrategy.ONLY_ADDstrategy (#461, #512, #514)- All styles managing trailing commas by default now (#216, #442)
- Removed mvn build scripts
- Corrected reference to jar in formatter website's command line instructions https://facebook.github.io/ktfmt/
- Trailing comma on when cases (#376)
- Update idea plugin name to avoid collision with google-java-format (#553)
- Update to Kotlin 2.2.0 (https://github.com/facebook/ktfmt/commit/451be91d53aafcaae01cf0f7f3e389cfb8eefac3)
- Update
kotlin-compiler-embeddableto2.2.0-Beta2for forward compatibility with context parameters. (#538) - Moved ktfmt project to Gradle (away from Maven) (https://github.com/facebook/ktfmt/commit/d03a29e71ebf19873e8b9ac21d255c8f830ef00a)
- Comments respecting max line width (#511)
- Exception while parsing property accessor on Kotlin 2.0.20-Beta2+ (#513)
- Updated Google Java Format to 1.23.0 (https://github.com/facebook/ktfmt/commit/ed949e89eea22843ac10d4fb91685453754abd25)
- IntelliJ plugin crash (#501)
- Ordering of
@propertyand@paramin KDoc (#498) - Annotation in return expressions (#497)
- KotlinLang style also managing trailing commas (#216, #442)
- Converted IntelliJ plugin to Kotlin (#502)
- More stability tests (#488)
- Custom profile in plugin settings, mirroring Gradle/Maven plugins (#503)
- Created CHANGELOG.md
- Added --help option to CLI (#477)
- Preserves blank spaces between when clauses (#342)
- Named the default style as
Formatter.META_FORMAT/--meta-style(https://github.com/facebook/ktfmt/commit/96a7b1e2539eef43044f676f60400d22265fd115) FormattingOptionsconstructor parameters order was changed (https://github.com/facebook/ktfmt/commit/520706e6d010d48619781d7113e5b1522f07a2ba)
- Compilation issues with online formatter (https://github.com/facebook/ktfmt/commit/8605080cb0aadb7eaba20f3b469d6ddafe32c941)
- Removing valid semicolons (#459)
- Incorrect detection of unused
assignimport (#411)
- Deleted
Formatter.DROPBOX_FORMAT/--dropbox-style(BREAKING CHANGE) (https://github.com/facebook/ktfmt/commit/4a393bb8c1156a4a0fd1ab736c02ca8dbd39a969) - Deleted
FormattingOptions.Styleenum (https://github.com/facebook/ktfmt/commit/7edeff14c3738427e53427eb6e39675dc30d1d05)