/AndroidPlayground

Android Studio initial project template for new projects

Primary LanguageKotlin

AndroidPlayground

Android Studio initial project template for new projects

ktlint rules setup

it makes Intellij IDEA's built-in formatter produce 100% ktlint-compatible code.

Option #1 (recommended)

(inside project's root directory)

ktlint applyToIDEAProject
# or if you want to be compliant with Android Kotlin Style Guide
ktlint --android applyToIDEAProject
Option #2

Apply to all IDEA projects:

$ ./ktlint applyToIDEA

Or if you want to use android specific code style:

$ ./ktlint --android applyToIDEA
Option #3

Go to File -> Settings... -> Editor

  • General -> Auto Import
    • check Optimize imports on the fly (for current project).
  • Code Style -> Kotlin
    • Set from... -> Predefined style -> Kotlin style guide (Kotlin plugin 1.2.20+).
    • open Code Generation tab
      • uncheck Line comment at first column;
      • select Add a space at comment start.
    • open Imports tab
      • select Use single name import (all of them);
      • remove import java.util.* from Packages to Use Import with '*'.
    • open Blank Lines tab
      • change Keep Maximum Blank Lines / In declarations & In code to 1 and Before '}' to 0.
    • (optional but recommended) open Wrapping and Braces tab
      • uncheck Method declaration parameters / Align when multiline.
    • (optional but recommended) open Tabs and Indents tab
      • change Continuation indent to the same value as Indent (4 by default).
  • Inspections
    • change Severity level of Unused import directive and Redundant semicolon to ERROR.