Skip to content
This repository was archived by the owner on Aug 9, 2026. It is now read-only.

Repository files navigation

ktfmt-pre-commit-hook (Archived)

This repository is deprecated and archived.

Please use:

https://github.com/macisamuele/language-formatters-pre-commit-hooks

which now includes support for ktfmt.

Why?

This repository originally provided a dedicated pre-commit hook for https://github.com/facebook/ktfmt.

Since ktfmt support is now available in language-formatters-pre-commit-hooks, maintaining a separate repository no longer provides value.

Migration

Replace:

- repo: https://github.com/davehadley/ktfmt-pre-commit-hook
  rev: <version>
  hooks:
  - id: ktfmt

with:

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
  rev: <version>
  hooks:
    - id: pretty-format-kotlin
      entry: mise exec -- pretty-format-kotlin
      args: [--ktfmt, --autofix]

ktfmt-pre-commit-hook

Main Build status Develop status License Last commit Last release

A pre-commit hook to run ktfmt.

Requirements

This commit hook requires Python >=3.8.

ktfmt requires Java 11. The java in your PATH must be version >=11.

Usage Instructions

Add the following lines to your .pre-commit-config.yaml.

- repo: https://github.com/davehadley/ktfmt-pre-commit-hook
  rev: 0.8.0
  hooks:
  - id: ktfmt
    stages: [commit]

To specify a specific version of ktfmt pass --version=XX.YY.ZZ with the args option. All other args provided will be passed onto ktfmt. For example:

- repo: https://github.com/davehadley/ktfmt-pre-commit-hook
  rev: 0.8.0
  hooks:
  - id: ktfmt
    args: [--version=0.53, --dropbox-style]
    stages: [commit]

See the ktfmt documentation for supported command line arguments.

Please report any bugs in the issue tracker.

Development Instructions

Environment Setup

Run source setup.sh to setup the development environment. This may be slow the first time that this is run as the virtual environment is created and dependencies are installed.

Testing

Run:

poetry install
poetry run pytest tests

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

A pre-commit hook for ktfmt.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages