A mix format plugin that
formats ~TYPST sigils and .typ files with
typstyle.
Setup
Add it as a plugin to your .formatter.exs, and include the .typ extension in inputs
to format templates that are next to their modules:
[
plugins: [Typsty.Formatter],
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs,typ}"]
]Options
These options go in .formatter.exs too:
:typst_line_length- the maximum line length for templates. Defaults to the formatter's:line_length, or 98.:typst_indent- the number of spaces to indent by. Defaults to 2.:typst_wrap_text- whether to wrap long lines of text in markup. Defaults tofalse.
The line length applies to the template itself: lines in a ~TYPST heredoc are also
indented by the Elixir code around them.
To leave a sigil as it is, use the noformat modifier: ~TYPST"""..."""noformat.
A template with syntax errors can't be formatted, so formatting it raises
Typsty.SyntaxError, the way mix format fails on invalid Elixir code.