bynk_fmt/lib.rs
1//! `bynk-fmt` — the Bynk formatter.
2//!
3//! A real leaf crate: the formatter is an AST-walk over the `bynk-syntax`
4//! types, so it depends on `bynk-syntax` only and never links the compiler
5//! (resolver/checker/emitter). Slice 2 of the crate-decomposition track moved
6//! the implementation down here from `bynkc::fmt` and re-pointed it onto the
7//! `bynk-syntax` leaf, turning the former cosmetic façade into the home of the
8//! formatter itself. `bynkc`'s own `bynkc fmt` command reaches it via
9//! `bynk-driver::run_fmt` (R10.4 residue, #1048: `bynkc` no longer re-exports
10//! this crate as `bynkc::fmt`).
11
12mod config;
13mod fmt;
14
15pub use fmt::{FormatError, FormatOptions, IndentStyle, format_source};
16// v0.123 (editor-currency slice 2): the surface renderers for an expression and
17// a refinement, exposed so `bynk-lsp` hover renders predicates / `where`
18// clauses through the formatter's own logic rather than a copy that could drift.
19pub use fmt::{expr_to_string, refinement_to_string};
20// v0.137.0 (ADR 0161): the storage-annotation renderer, exposed so `bynk-lsp`
21// agent-state hover renders a `store` field's `@indexed`/`@bounded`/… through
22// the formatter's own logic rather than a drift-prone copy.
23pub use fmt::annotation_to_string;
24// v0.166 (#616): the string-literal escaper, exposed for the same reason — an
25// actor's `auth = Scheme(secret = "…")` config holds the *unescaped* value (the
26// parser resolves escapes at lex time), so `bynk-lsp` hover must re-escape it to
27// render valid Bynk, exactly as `format_actor` does. Without it the two renderers
28// agree until the value contains a `"` or a `\`.
29pub use fmt::escape_string;
30
31// #972: the `[fmt]` section of a project's `bynk.toml`, layered under the CLI's
32// own flags by `bynkc fmt`/`bynk fmt` and read directly by `bynk-lsp` for
33// format-on-save. One reader for one section — the two front-ends previously
34// had only the language server reading it at all, so a project that set a style
35// there saw the editor and the command line disagree.
36pub use config::{ConfigError, FmtConfig, MANIFEST, find_manifest};