typstfmt icon indicating copy to clipboard operation
typstfmt copied to clipboard

chore: add `.pre-commit-hooks.yaml`

Open 34j opened this issue 1 year ago • 5 comments

This PR adds a pre-commit hook.

34j avatar Jun 12 '24 11:06 34j

Can you say why we need this?

jeffa5 avatar Oct 12 '24 17:10 jeffa5

Sorry for your confusion, you could refer to my explanation in an similar PR for another typst formatter:

https://github.com/Enter-tainer/typstyle/pull/91#issuecomment-2162852338

In short by this change typstfmt can be automatically run every time before commiting

34j avatar Oct 14 '24 02:10 34j

Ah, so its some config that people reference from their repos to keep things in check. Ok, how does it build typstfmt then? Or does it just assume its in their path?

jeffa5 avatar Oct 14 '24 08:10 jeffa5

pre-commit creates a virtual environment and installs it there (as I specified rust), so there is no need for the user to manually install it. Although I am not sure what specific commands are used.

34j avatar Oct 14 '24 13:10 34j

.pre-commit-config.yaml:

repos
  - repo: https://github.com/34j/typstfmt
    rev: "872b6b9"
    hooks:
      - id: typstfmt
pipx install pre-commit
pre-commit run -a

image

1-2 minute(s) later

image

34j avatar Oct 14 '24 13:10 34j

Thanks for the explanation!

jeffa5 avatar Oct 24 '24 07:10 jeffa5