-
Notifications
You must be signed in to change notification settings - Fork 30
new feature: Line lengths and auto-wrapping #59
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
base: master
Are you sure you want to change the base?
Conversation
|
I was planning to have a single int-valued "rightMargin" setting and several boolean-valued settings like "reflow strings", "reflow comments", "reflow method calls" etc. Do you think we need the option to have different margins for strings, comments and method calls? How might that config look?
I'm not sure yet. I was expecting to do all the other formatting first, then add extra breaks only when the line was over-long. After adding extra breaks, I'd then re-apply all the normal formatting. For example, a one-line method call like might get reformatted to just add spaces: But only if it went over the right margin would the "reflow method calls" format come into play: and then that "reflown" method call would need reformatting according to the current preferences like "alignArguments" (EDIT: and the "dangling close parenthesis" setting, see #29).
Currently it's well isolated, so it's easy to have an on/off flag. I think this is likely to stay the same, as there will always be a single "entry point" to the reflowing where the current text is compared to the current margin. I think it's likely to be a setting where individual preferences will differ. Some people are very keen on strict 80-char lines, and some people think that's pedantic nonsense and are happy with 150-char lines. It's also a more invasive reformatting than many of the rules. IMO this is one that does need an option to control it.
My plan was to have all the "reflow" formatters controlled by a single "rightMargin" setting, so I think this question doesn't arise, unless I've misunderstood you?
OK, thanks. You didn't directly address "if you'd merge them in if I were to finish up and submit them here", but it sounds like you would? |
* Fix off-by-one re line lengths -- an 80 wide line means that the "\n" is the 80th char.
ce2a3af to
a733491
Compare
|
(I've added support for reflowing "//" style comments to the PR. I'm still working on the other TODOs listed above.) |
|
Great feature addition. Can you add a setting for the closing paren placement? I would love to see the outcome of a split turn out to be |
I agree that this needs a setting. |
|
Interesting prior work re auto-breaking lines and how hard it is: |
|
Hey @RichardBradley, scalariform has new maintainers. Are you interested in bringing this PR back to live? You would have to rebase against the master branch of https://github.com/scala-ide/scalariform |
|
I'm not working on Scala at the moment (boo), but I might come back to this at some point in the future. My work so far is here if anyone wants to pick this up or use parts of it. I'll reopen at that location if I return to this. I think this would be a very valuable feature to some users (but not all), but after reading the posts I linked to above, I'm worried that this might be very difficult or impossible to get right in all cases. Reflowing comments (the work so far) is useful and more approachable than reflowing code. |
This PR is a work in progress towards some new scalariform rules to help auto-format overly long lines.
I've started by introducing two new settings: "
rightMargin" (default 100) and "reflowComments" (default "true").So far this will reflow Scaladoc style comments if they are over 100 chars wide.
This works and is tested, so is ready to merge now if you like, or fine to wait for the extra features discussed below.
It includes #57 and #58 as it would conflict if submitted separately.
I'd like to add support for reflowing / autobreaking of:
Please could you let me know:
Thanks,
Rich