You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The flake provides an overlay which you can use with nixpkgs.
pre-commit
Add this to your .pre-commit-config.yaml:
- repo: https://github.com/jeffa5/typstfmtrev: ''# Use the sha / tag you want to point athooks:
- id: typstfmt
Run
# format stdin
typstfmt
# format typst files in current directory
typstfmt *.typ
Nix
nix run github:jeffa5/typstfmt
Configuration
You can configure some aspects of the formatting with a typstfmt.toml file in the current directory, or specify its location with the --config-path flag.
The default configuration is:
indent = 2# spacesspacing = true# whether to manage spacing
Development
Fuzzing
List some fuzz targets:
cargo fuzz list
Then run one, e.g. for crash_proof:
cargo fuzz run crash_proof
Testing against the package repo
The typst packages repo is a submodule (typst-packages).
We can run the formatter against it to check the formatting and for erroneous outputs with:
cargo run -- typst-packages --check
And try to format them all (useful for manual diffing):
cargo run -- typst-packages
Acknowledgements
typstfmt is a rewrite of typst-fmt which aims to retain all original text whilst also be able to be flexible in its configuration.
I tried writing some rules for that formatter before beginning the redesign present here.