Closed 0x26res closed 3 months ago
I would not have objections on supporting formatting via ktfmt.
Eventually it could be integrated via a flag on the already existing kotlin formatter to avoid the presence of 2 kotlin related for matters.
I can suport you with PR review and scoping out some of the possible CLI arguments. And yes your concern is valid, we should aim to not depend on maven or grade but only java (and I believe that it is possible)
It seems this issue was resolved by #196
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-lineIf 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 eithergradle-spotless
ormaven-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).