lattice_format/lib.rs
1//! External formatters, and how their output reaches a buffer.
2//!
3//! The external-tool half of auto-indent
4//! (`docs/dev/architecture/auto-indent.md` §8). Where the indent engine
5//! answers "which column does this line start at" synchronously from a
6//! parse tree, this runs somebody else's program and turns its opinion
7//! into edits.
8//!
9//! Three concerns, three modules, because they fail differently:
10//!
11//! - [`spec`] — which program, per language. Data.
12//! - [`runner`] — spawning it, with a timeout and a typed error per
13//! failure mode. Blocking; the caller puts it on `spawn_blocking`.
14//! - [`apply`] — whole-file output → a **minimal** edit set, never a
15//! buffer-wide replace.
16//!
17//! ## Why this is a crate and the indent engine is not
18//!
19//! `lattice-indent` was proposed, built and collapsed into
20//! `lattice-syntax` during IN.1: a pure tree walk driven by `.scm`
21//! files belongs beside the other tree walks. This is genuinely
22//! different work — process spawning, a timeout policy, stderr
23//! handling, diff-based edit derivation — and none of it belongs in a
24//! syntax crate.
25
26pub mod apply;
27pub mod runner;
28pub mod spec;
29
30pub use apply::{changes_more_than_indentation, minimal_edits};
31pub use runner::{FORMAT_TIMEOUT, FormatError, run};
32pub use spec::FormatterSpec;