Incidentally I spent yesterday implementing a Lisp formatter with the algorithm described by Jean-Philippe Bernardy in the simple and elegant paper "A Pretty But Not Greedy Printer."
https://jyp.github.io/pdf/Prettiest.pdf
It's based on introducing choice between vertical and horizontal stacking. It avoids combinatorial explosion by pruning away strictly suboptimal choices. With just a few extra rules for Lisp forms, the results are quite good.
I don't handle comments though, since I only need it for pretty printing values so far.