Skip to content
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

Support vertical alignment #1103

Closed
wuranbo opened this issue Jul 19, 2016 · 8 comments
Closed

Support vertical alignment #1103

wuranbo opened this issue Jul 19, 2016 · 8 comments
Labels

Comments

@wuranbo
Copy link

wuranbo commented Jul 19, 2016

Could the rustfmt support vertically align as default? At least it can be configured not to break the vertically aligned code when try to format codes include them.

Many people love it.
https://shkspr.mobi/blog/2014/11/why-i-vertically-align-my-code-and-you-should-too/

And another support is the gofmt use vertical alignment https://golang.org/doc/effective_go.html#formatting .

@duesee
Copy link

duesee commented Aug 9, 2016

There is an ongoing effort to find out which style is preferred across the community. Maybe you should try your luck here: rust-lang/rfcs#1607

AFAIK rustfmt will stick to the style agreed on in the RFC.

@wuranbo
Copy link
Author

wuranbo commented Aug 10, 2016

Thank you @duesee , I already did it. And I saw the RFC, it is targeting to get 'the decision process for the coding style', and it also said at last we will get the recommended style, and rustfmt will impl it as default style, leave others configurable. So whether the vertically align is choiced to be the recommended style, it can be implemented in rustfmt as a configuration.

@wuranbo wuranbo changed the title Could the rustfmt support vertically align as default? Could the rustfmt support vertically align as a configuration? Aug 10, 2016
@wuranbo
Copy link
Author

wuranbo commented Aug 10, 2016

And another support is the gofmt use vertical alignment https://golang.org/doc/effective_go.html#formatting .

@nrc nrc changed the title Could the rustfmt support vertically align as a configuration? Support vertical alignment Jan 25, 2017
@flosse
Copy link

flosse commented Jun 15, 2017

Are there any updates?

@nrc
Copy link
Member

nrc commented Jun 15, 2017

Are there any updates?

No, sorry. I would take a PR for this if there was a fairly complete implementation, but I don't have time to work on it myself and there is a lot of higher priority work (better support for the default options, basically) to point people at.

@synek317
Copy link

synek317 commented Mar 6, 2020

I guess there is still no update on this.

Is this still true?

I would take a PR for this if there was a fairly complete implementation

If yes, I would like to at least try to implement this feature, I really miss it 🙃

@alexmozaidze
Copy link

It would actually be really cool if it worked on per "code block" basis like this:

// this would get vertically aligned
#[rustfmt::vertical_align]
const PLAYER_MONEY: f32 = 32.0;
const PLAYER_VERY_LOOOOONG_CONSTANT: u32 = 0;

// this would not since it's separated with a newline
const ENEMY_MONEY: f32 = 23.0;
const ENEMY_VERY_LOOOOONG_CONSTANT: u32 = 0;

so it would be possible to tell it what to and what not to align vertically.

@calebcartwright
Copy link
Member

Closing as this issue is quite old and has outlived its relevancy.

The defaults were established many years ago and are not going change. However, those that prefer the vertical/visual layout can utilize existing options like indent_style and struct_field_align_threshold.

There are certainly still gaps in places where vertical/visual alignment is only partially support and others not yet at all, but those are best tracked in their respective issues (e.g. #894). Anyone willing and interested in improving vertical/visual support should certainly feel free to do submit patches for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants