to use it:
-
install ktlint first:
brew install ktlint
- if not on mac, use different installation: https://github.com/pinterest/ktlint -
modify your pre-commit file in .git folder
-
create .editorconfig file in root of your project
example config of .editorconfig:
[*.{kt,kts}]
indent_size = 2
indent_style = space
now commit ... ktlint will automatically format Kotlin source files using ktlint before committing changes in a Git repository.