gleamunison/formatter

Opinionated formatter for gleamunison surface syntax (roadmap 9.2).

One rule, no configuration:

Formatting is a pure function of the parse tree, so it is idempotent by construction. Comments are data, not casualties: a comment before a form stays before it, a comment on a form’s line trails that line, and a comment written inside a form stays inside it, on the line above the child that followed it. A comment inside a form forces that form to break, because flat text has nowhere to put one and dropping it is not an option. ’x prints as (quote x).

Values

pub fn format_source(
  src: String,
) -> Result(String, lexer.ParseError)

Format a whole source file: every top-level form on its own line(s), forms separated by single newlines, comments preserved in place, trailing newline at the end.

✨ Search Document