Right now the formatter changes 1+n:5 to 1 + n:5 which is confusing. Perhaps (1 + n):5 could be used instead?
Hm, I'm not sure we want the formatter to ever add things like parenthesis, I think it should probably stay with adding and removing whitespaces and line breaks. But maybe it just shouldn't add whitespaces in range expressions?
I'd quite like this as an opt-in configurable option, the inverse relation between whites space distance and precedence confuses me
I tend to write the arithmetic with no spaces and no parens in this situation, but realize some people find that objectionable. The parenthesized form is ok as well, but the wide spaced non-parens form is actively misleading in appearance.
So I think the formatter should then a) remove whitespaces in range expressions that don't use parenthesis, and b) add whitespaces in range expressions that do use parenthesis. But I feel pretty strongly that the formatter should never add or remove parenthesis, that to me is more of a refactoring than a formatting change.
if there's whitespace in an expression on either side, I tend to think it's more readable to also add spaces around the colon
Closing this, if there's any further interest continue it at https://github.com/zacln/documentformat.jl