-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make juvix format
line width 100 with ribbon width 100
#2883
Conversation
Two questions: |
VSCode with two panes on my 24 inch screen with a 14pt font and 1920x1080 resolution. Then one pane displays 80-something characters.
I don't think so. It's not Java. The rest of the language is quite succinct, so there's space for variable names. Plus, you put newlines a lot more, with every case etc. 80 is not such a small number. We're basically using around 80 characters per line in our Haskell code. I definitely don't write much longer lines. It works well. |
It is also worth noting that
|
There’s a point here. I think ormolu doesn’t break the lines by itself either, only in situations when e.g. there is already one newline after a case. The question is how uniform we want to be. Though “wrap it and indent with an extra tab” doesn’t work too well with complex code structure - quickly becomes unreadable when there are many such lines. |
I'd say not enforcing a line length limit is less strict than having an option to enforce different line length limits. It allows people to choose the line length arbitrarily and differently within even a single project. |
For me personally, ribbon width of 100 chars would still be palatable, but with anything longer than this used consistently I'd need to give up on two panes side by side. |
I think we can agree on this. Q: can we implement this using prettyprinter, if so what's the effort required? Perhaps @janmasrovira knows? |
Thanks - I'll update this PR to line width 100 and ribbon width 100 (i.e |
For clarity I didn't make this comment to endorse all of gofmts design choices, just the maxim. |
Palatable, but a bit inconvenient. I won't protest against ribbon width 100, but would prefer something a bit smaller. |
juvix format
line width 100 with ribbon width 80juvix format
line width 100 with ribbon width 100
I'm fine with either choice. Let's try it for a while, if we feel like it can be improved, we can always change it. I'd like to add that we don't respect the user newlines by design. The goal of our formatter is indeed to make code look readable, but also (and not less important) to remove as much formatting responsability from the user as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now realize that some changes are needed in the Format.juvix test.
Some lines were written with the intention to force the formatter to introduce a newline.
Thanks - I'll fix these now |
2e365fe
to
3160f92
Compare
The existing highlight smoke test contains assertions included newlines. The newlines are no longer present now we have changed the desired line length of the output. To fix this we use the YAML trim annotation `-`, so we're only asserting the text rather than the text and the trailing newline.
3160f92
to
8d2ab9d
Compare
This PR increases the ribbon width of
juvix format
from 60 to 100 characters.Reasons for the compromise to a fixed 100 chars ribbon width:
Definition of ribbon width from the docs
Examples from
anoma-app-patterns:/Token/Transaction.juvix
. NB: The file in the repo is unformatted so will not match the layout in the left column below.