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: full-line comments stay before their form, a trailing comment joins its form’s first line, and a comment inside a form hoists above the form (documented approximation — never dropped). ’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 (see module docs), trailing newline at the end.

✨ Search Document