Range rewrite
Add an optional arg to current interface to perform certain action on source code ranges.
fn pretty_print(content: &str, width: usize, actions: Vec<(start, end, RewriteAction)>)
, where action is an enum defined in typstyle. It can be ToMultiline, ToSingleLine, ToBlockEquation, ToInlineEquation, NoFormat...
typstyle will find the first ast node(in order traversal) which is contained by the provided range.
When certain action is not applicable, it will be sliently ignored
a builder/worker style may be more flexible, like std::process::Command.
a builder/worker style may be more flexible, like
std::process::Command.
Do you mean a PrettyPrinterBuilder? It's Ok for me. Like
PrettyPrinterBuilder::new()
.with_column_width(..)
.with_content(...)
.with_actions(...)
.format()
It could be less flexible:
PrettyPrinterBuilder::new(column_width or config)
.with_actions(...)
.format(content)
Looks similar to the nixfmt or ra-fmt declarative DSL style. Works very well with CST interfaces like Typst has.
https://www.github.com/rust-lang/rust-analyzer/pull/1678 https://github.com/nix-community/nixpkgs-fmt/
https://www.github.com/rust-lang/rust-analyzer/issues/1665