Typstyle

Integrations

Typstyle integrates with editors, continuous integration, and version-control workflows.

Editor Integration

Typstyle has been integrated into tinymist. You can use it in your editor by installing the tinymist plugin and set tinymist.formatterModetinymist.formatterMode to typstyletypstyle.

VS Code (via Tinymist)

  1. Install the Tinymist extension
  2. Set tinymist.formatterModetinymist.formatterMode to "typstyle""typstyle" in your settings
  3. Enable format on save or use Ctrl+Shift+PCtrl+Shift+P → “Format Document”

GitHub Actions

The typstyle-action maintained by grayespinoza can install and run Typstyle in a GitHub Action.

- name: Run typstyle
uses: typstyle-rs/typstyle-action@main
- name: Run typstyle
uses: typstyle-rs/typstyle-action@main

Pre-commit Hook

Add this to your .pre-commit-config.yaml.pre-commit-config.yaml:

- repo: https://github.com/typstyle-rs/pre-commit-typstyle
rev: '' # The revision or tag you want to use
hooks:
- id: typstyle
- repo: https://github.com/typstyle-rs/pre-commit-typstyle
rev: '' # The revision or tag you want to use
hooks:
- id: typstyle

Working with Jujutsu

Typstyle works with Jujutsu through its jj fixjj fix command. jj fixjj fix does not run formatters on paths in the working copy: it writes the content of each selected file to stdin and reads the formatted content from stdout. Use the plain typstyletypstyle command as the fix tool:

[fix.tools.typstyle]
command = ["typstyle"]
patterns = ["glob:'**/*.typ'"]
[fix.tools.typstyle]
command = ["typstyle"]
patterns = ["glob:'**/*.typ'"]

Style options can be passed the same way, for example command = ["typstyle", "--line-width=100"]command = ["typstyle", "--line-width=100"].

Do not add -i-i to the command: in-place mode requires file arguments and is rejected when typstyle reads from stdin. Do not pass $path$path either, since a path argument makes typstyle read the working-copy file and ignore stdin. A file that cannot be parsed is echoed unchanged with a successful exit code, so jj fixjj fix leaves it intact.

Because jj fixjj fix selects files by fileset, its selection is independent of typstyle’s directory walking: tracked Typst files under dot-directories are formatted as well. When you run typstyle directly in a Jujutsu workspace, recursive directory walks skip entries whose names start with a dot, so .jj.jj and the .git.git directory of a colocated repository are never touched.

ℹNote
line-range-argsline-range-args is not supported because the typstyle CLI has no line-range option. jj fixjj fix therefore formats whole files.