I tried to nail down ubiiquitous formatting for a typed nl-like sexpr language I have been mostly vibe coding.
It is surprisingly hard. I ended up mostly copying the algorithm that can be used through raco (the racket command line tool). It is not particularly fast, only about 10lines of code per core-second, but it produces a good enough result. I had to leave some things to the user, but only about 5 forms.