Skip to content

Releases: facebook/ktfmt

0.24

27 Mar 07:40
Compare
Choose a tag to compare

Bug fixes:

  • Don't add spaces in KDoc, not even after links. (fixes #190)

Artifacts will be shortly available at Maven Central: https://search.maven.org/artifact/com.facebook/ktfmt/0.24/jar

0.23

23 Mar 08:40
Compare
Choose a tag to compare

This release tests a triggering a GitHub Action for publishing the IntelliJ plugin.
No need to upgrade from 0.22.

0.22

19 Mar 09:45
Compare
Choose a tag to compare

Bug fixes:

  • Handle nested KDoc (/** /* foo */ */)
  • Handle function type params of the form @annotation (<lambda>) (#189)
  • Handle semicolons between when entries

Other:

  • All files in args are processed, even if one of them has an error (oops)

Artifacts will be shortly available at Maven Central: https://search.maven.org/artifact/com.facebook/ktfmt/0.22/jar

0.21

26 Feb 18:07
Compare
Choose a tag to compare

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.

0.20

20 Feb 20:01
Compare
Choose a tag to compare
  • Handle function references of nullable types (e.g., String?::nullOrEmpty)
  • Handle package names with escaped identifiers (e.g., package foo.when)
  • Allow a line break after a destructuring's assignment
  • (--google-style) when(): fix multiline arguments
  • (--google-style) If: put closing paren on next line
  • Relax conditions for 1-line annotations in expresssions
  • Keep so-called "scoping functions" on same line as assignment (#161)
  • Preliminary support for .kts files
  • Remove Kotlin 1.3 support
  • (--google-style) Break before each call parameter if they don't all fit in one line (#67)

Get it on Maven Central: https://search.maven.org/artifact/com.facebook/ktfmt/0.20/jar

0.19

23 Dec 17:06
Compare
Choose a tag to compare

Significant changes:

Now using Kotlin 1.4

In particular, fun interface is now supported.

Do not break due to annotations parameters

@Dimenstion(unit = DP) @Px fun g(): Int = 5

instead of

@Dimenstion(unit = DP)
@Px
fun g(): Int = 5

Break after each class/fun param, if they don't all fit in one line

fun foo12(
    a: Int,
    var b: Double,
    val c: String
) {
    //
}

instead of

fun foo12(
    a: Int, var b: Double, val c: String
) {
    //
}

Don't break before lambda when initializing property

val lambda = {
  ...
}

instead of

val lambda =
    {
      ...
    }

Constructor is now indented on level of class

class Foo
constructor(
    a: Int,
    b: Int
)

instead of

class Foo
    constructor(
        a: Int,
        b: Int
    )

Other changes

  • Fix: Handle ; between property and accessor (e.g., var x = false; private set)
  • Fix: Don't break after variable declaration in when expression (e.g., when (val y = x.improved()) { … } )
  • Fix: Allow line breaks after as and is
  • FIx: Fix comment indent inside of lambdas
  • Fix: Make secondary constructors more like function declarations
  • Fix: Don't crash on trailing commas in lambdas parameters

Get it on Maven Central: https://search.maven.org/artifact/com.facebook/ktfmt/0.19/jar

0.18

18 Aug 19:41
Compare
Choose a tag to compare

This release only contains internal changes required by the new IDEA plugin. In particular, ktfmt now uses kotlin-compiler-embeddable.

Get it on Maven Central: https://search.maven.org/artifact/com.facebook/ktfmt/0.18/jar

0.17

08 Aug 17:39
Compare
Choose a tag to compare

Release Notes

ktfmt now removes unused imports - but there may be false positives! please report any issues.

New:

  • Remove unused imports
  • Bug fix: Preserve expressions appearing on the same line as imports
  • Rewrite formatting code for call-expression and qualified-expression to fix several bugs
  • Support trailing commas

Get it on Maven Central: https://search.maven.org/artifact/com.facebook/ktfmt/0.17/jar

0.16

16 Jul 15:25
Compare
Choose a tag to compare

This version only contains an internal change meant to make it easier to use with Spotless.

Get it on Maven Central: https://search.maven.org/artifact/com.facebook/ktfmt/0.16/jar

0.15

07 Jul 17:00
Compare
Choose a tag to compare

This version contains tags 0.14 and 0.15; there's no separate v0.14 release.

Release Notes:

  • Handle annotations with type arguments (fixes #48)
  • Fit annotations in one line when possible
  • Handle multi-annotations with use-site targets (fixes #51)
  • Handle the 'dynamic' keyword (#50)
  • Avoid closing block in qualified expression for non-lambdas
  • Fix breaking after = for a property with no type and many annotations
  • Preserve existing line breaks in output (\n, \r or \r\n)
  • Don't add a newline between package and the next element when there are no imports
  • Correctly indent blocky expressions in if-else
  • Fix bug in all-under import deduplication
  • Fix super statements without labels
  • Support super expressions with type qualifier
  • Fix space after return with no value
  • ktfmt now drops redundant semicolons
  • Better formatting for qualified expressions
  • Support suspended types (#33)

Get it on Maven Central: https://search.maven.org/artifact/com.facebook/ktfmt/0.15/jar