GDScript formatter.
Formatting runs in two stages. Lowering turns the concrete syntax tree into a document describing where lines may break, and the renderer decides where they do, given the configured width. Keeping those apart means the style-guide rules live in one place instead of being spread across string concatenation.
What the guide asks for
Most of it falls out of the document IR: the 100-column wrap, one space around operators and after commas, two blank lines around top-level definitions and one inside a class, trailing commas on collections that break, and two indent levels on continuation lines against one inside arrays, dictionaries and enums.
The rest is explicit: quote style chosen to minimise escapes, lowercase
hexadecimal, a digit either side of a float's point, single-line inner
class declarations, and redundant parentheses dropped. Those live in
the literal and lower modules.
Safety checks
Before returning, the formatter re-parses its own output and checks that it
still parses, that the tree still means the same thing, that no comment was
dropped, and that a second pass is a no-op. A formatter that silently eats code is far
worse than one that refuses to run, so these are on by default;
[FormatConfig::safety_checks] turns them off.