-
Notifications
You must be signed in to change notification settings - Fork 68
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
Align trailing comments #252
Comments
This is an interesting one, because it leads us onto something else to consider: should StyLua purposefully align items, such as comments? I know its something done in Back to your original suggestion of keeping the spacing of comments alone in the first place, one thing I try not to do is rely on the input AST too much for formatting choices. In the case you mentioned it works because you are trying to align things, but it also starts affecting places where you want stylua to remove the spacing. local x = 1 -- i did some refactoring leaving spacing before this comment, i want it removed |
in your example, it's not an inline comment on a type/argument/table element list. forcing alignment in those cases is interesting, but as you mention it then requires a larger AST block to be the basis of the analysis/formatting, potentially opening up a can of worms in terms of complexity/accuracy. |
ping on this. is this doable for argument, type, and table lists? |
I'm still not 100% because it opens a gap in the automated formatting. |
Another use case to consider for this is when lining up equal signs: {
foo_bar = { a = 10, b = 2 },
fo_br = { a = 100, b = 2 },
foo = { a = 1, b = 2 },
fooo_bar = { a = 1000, b = 2 },
} vs. {
foo_bar = { a = 10, b = 2 },
fo_br = { a = 100, b = 2 },
foo = { a = 1, b = 2 },
fooo_bar = { a = 1000, b = 2 },
} The ability to quickly parse the data structure and see the common elements is very nice in my opinion. |
As as side note, luals does this by default through EmmyLua |
in this example, spacing before and inside of comments is key to legibility (in fixed-width font, anyway):
the aligned comments become this:
The text was updated successfully, but these errors were encountered: