Show HN: CodeBuff – smart code formatter
github.com
github.com
The difficulty is tying it to a particular language's parser and whitespace rules.
Then, when we parse a new file to pretty-print, we parse again with the _same parser_ and the features that were learned are matched to the tree at hand to recover the "right" spacing and indentation features for the given example code.
For the users for a specific language it could also be an improvement since configuration of a formatter can be done via completely arbitrary code examples. But we have to work a bit further to streamline that use case.