Crates.io | templr_formatter |
lib.rs | templr_formatter |
version | 0.1.1 |
source | src |
created_at | 2024-01-09 22:09:30.298026 |
updated_at | 2024-04-14 11:29:28.763296 |
description | Formatter for the templr templates library |
homepage | https://github.com/PizzasBear/templrfmt |
repository | https://github.com/PizzasBear/templrfmt |
max_upload_size | |
id | 1094680 |
size | 237,195 |
Formatter for the templr templates library.
cargo install templrfmt
Usage: templrfmt [OPTIONS] [INPUT_PATTERNS]...
Arguments:
[INPUT_PATTERNS]... A space separated list of file, directory or glob
Options:
-s, --stdin Format stdin and write to stdout
-r, --rustfmt Format with rustfmt
-q, --quiet
-h, --help Print help
-V, --version Print version
You can set the rust-analyzer.rustfmt.overrideCommand
setting.
"rust-analyzer.rustfmt.overrideCommand": ["templrfmt", "--stdin", "--rustfmt"]
The pretty-printer is based on Philip Karlton’s Mesa pretty-printer, as described in the appendix to
Derek C. Oppen, “Pretty Printing” (1979), Stanford Computer Science Department STAN-CS-79-770.
This algorithm's implementation is taken from prettyplease
which is adapted from rustc_ast_pretty
.
The algorithm takes from an input stream of length n
and an output device with margin width m
,
the algorithm requires time O(n)
and space O(m)
.
The algorithm is described in terms of two parallel processes;
the first scans the input stream to determine the space required to print logical blocks of tokens;
the second uses this information to decide where to break lines of text;
the two processes communicate by means of a buffer of size o(m)
.
The algorithm does not wait for the entire stream to be input,
but begins printing as soon as it has received a linefull of input.