ktfmt
is a program that pretty-prints (formats) Kotlin code, based on google-java-format.
private fun declareOne( kind: DeclarationKind, modifiers: KtModifierList? = null, valOrVarKeyword: String? = null, typeParameters: KtTypeParameterList? = null, receiver: KtTypeReference? = null, name: String? = "", type: KtTypeReference? = null, op: String = "", equals: String = "=", typeConstraintList: KtTypeConstraintList? = null, initializer: PsiElement? = null, delegate: KtPropertyDelegate? = null, trailing: String? = null ): Int { // }
private fun declareOne( kind: DeclarationKind, modifiers: KtModifierList? = null, valOrVarKeyword: String? = null, typeParameters: KtTypeParameterList? = null, receiver: KtTypeReference? = null, name: String? = "", type: KtTypeReference? = null, op: String = "", equals: String = "=", typeConstraintList: KtTypeConstraintList? = null, initializer: PsiElement? = null, delegate: KtPropertyDelegate? = null, trailing: String? = null ): Int { // }
vendor/google-java/format
submodule is populated. Either clone with submodules (git pull --recurse-submodules https://github.com/facebookincubator/ktfmt.git
) or populate the submodule after cloning (git submodule update --init
)mvn install
java -jar core/target/ktfmt-0.1-SNAPSHOT-jar-with-dependencies.jar
ktfmt
uses a 2-space indent; why not 4?Two reasons -
vendor/google-java/format
submodule is populated. Either clone with submodules (git pull --recurse-submodules https://github.com/facebookincubator/ktfmt.git
) or populate the submodule after cloning (git submodule update --init
)pom.xml
in IntelliJ. Choose “Open as a Project”FormatterKtTest.kt
.Apache License 2.0