# `Typsty.Formatter`
[🔗](https://github.com/akoutmos/typsty/blob/0.1.0/lib/typsty/formatter.ex#L1)

A `mix format` [plugin](https://hexdocs.pm/mix/Mix.Tasks.Format.html#module-plugins) that
formats `~TYPST` sigils and `.typ` files with
[typstyle](https://github.com/typstyle-rs/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:

```elixir
[
  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 to `false`.

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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
