Maudfmt
An opinionated yet customizable Maud formatter.
Install
cargo install maudfmt
or for trying out unreleased features:
cargo install --git https://github.com/jeosas/maudfmt.git
Usage
Format files as arguments
- Providing files
maudfmt ./build.rs ./src/main.rs
- Providing a directory
maudfmt ./src
- Providing a glob
maudfmt ./{src, tests}/**/*
Format files through stdin
cat ./src/main.rs | maudfmt -s
Options
$ maudfmt --help
An opinionated yet customizable Maud formatter.
Usage: maudfmt [OPTIONS] [FILE]...
Arguments:
[FILE]... A space separated list of file, directory or glob
Options:
-s, --stdin Format stdin and write to stdout
-h, --help Print help
-V, --version Print version
IDE Setup
vim - conform.nvim
require.
Tips and Tricks
Magic comments
maudfmt automatically manages exanding and collapsing blocks depending on line length.
In some cases, would might prefer to expand a block even if it fits on a single line. To do this, you can use magic comments:
- on the opening bracket line:
p { //
"Small text"
}
- inside the block itself
p {
// either on an empty line
"Small text" // or as a trailing comment
}
doesn't matter if there is an actual comment, the
//comment marker is enough.
Acknowledgment
Special thanks to the creators and contributors of the following projects for their awesome work and inspiration
A note on non-doc comments
Currently this formatter does not support non-doc comments in code blocks (Splices).
It uses prettyplease for formatting rust code, and prettyplease does not support this.
This means that you can use non-doc comments throughout your view macro, as long as they don't reside within code blocks.
A bit more context:
prettypleaseusessynto parse rust syntax. According to https://doc.rust-lang.org/reference/comments.html#non-doc-comments non-doc comments are interpreted as a form of whitespace by the parser;synbasically ignores/skips these comments and does not include them in the syntax tree.