language-formatters-pre-commit-hooks
language-formatters-pre-commit-hooks copied to clipboard
Add support for ktfmt
At the moment the pretty-format-kotlin
hook uses ktlint.
ktfmt is another popular code formatter for koltin. It would be good if there was an extra hook in this repo (eg pretty-format-ktfmt
) that would use ktfmt.
I had a look at the code for pretty-format-kotlin
and it looks like it should be simple to implement a similar version for ktfmt. It's just a matter of calling java with a jar and the correct arguments: https://github.com/facebook/ktfmt#from-the-command-line
If that makes sense I can have a god at putting an PR together.
PS: so far the only way I found to run ktfmt with pre-commit is to use spotless
, with either gradle-spotless
or maven-spotless-apply
. But these hooks require either maven or gradle installed. Whereas in theory we only need java (and to download and cache the correct jar).