Uncheck optimize imports: Editor -> General -> Auto Import -> Optimize imports on the fly
Select: Editor -> Code Style -> Kotlin -> Imports -> Use single name import
You can manually invoke the tasks, but know they will be invoked on Git commit.
formatKotlin: format Kotlin source code according to ktlint rules or warn when auto-format not possible.
lintKotlin: report Kotlin lint errors and by default fail the build.
Create pre-commit hook, .git/hooks/pre-commit
#!/bin/sh
echo "Running formatKotlin check..."
./gradlew formatKotlin
if [ $? -ne 0 ]; then exit 1; fi
echo "Running lintKotlin check..."
./gradlew lintKotlin
if [ $? -ne 0 ]; then exit 1; fi
echo "Running detekt check..."
./gradlew detekt
if [ $? -ne 0 ]; then exit 1; fi
chmod +x .git/hooks/pre-commit