Rewrap-like functionality in a formatter

I have recently started messing with Zed as an editor. I really, really like it.

While I don’t go too heavy on extensions, one that I really love is Rewrap. Zed has native support for very basic rewrapping, but Rewrap is very smart about markdown in docstrings.

As much as I like Rewrap, what I have always actually wanted is a formatter to just enforce docstring formatting for a project. Save a file and boom… comments and docstrings are wrapped, period.

Before I start looking into external formatters (Zed has a nice pipeline for formatting through multiple commands) is this something that’s doable via mix format using a plugin?

1 Like

Formatter cannot change code semantics, which mean that it can wrap comments (and IIRC - it does) but it cannot wrap docstrings.

Where “strings” is the important part. Documentation is defined by providing a string value to a module attribute. That string value supports all manipulations available to any string in elixir, like string interpolation, concatination and so on. It’s not just plain text.