That’s fair, a rewrite based formatter would probably be a lot simpler to write, but I believe it’s also less valuable. The approach I chose is to drop all formatting except for newlines and comments. This way it takes more work to write a formatter that formats everything nicely again, but it also means it formats all nix code nicely, no matter how ugly the original was. I chose to avoid configurability because it leads to much less consistent formatting. I will probably introduce some rewrite rules in the future for cases where the AST needs to change though.
2 Likes