-
Notifications
You must be signed in to change notification settings - Fork 79
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
Luau: formatting IfExpression syntax #289
Comments
Some WIP text on our current thinking from @MagiMaster:
|
I like these ideas
|
I agree on the first point -- I was just including some of the surrounding language from the WIP text in the style guide for context. :) The other points, let me discuss with @MagiMaster , @ZoteTheMighty , @jeparlefrancais, @ktrz and we'll reply :) |
|
I think everyone agrees on point 1. For point 2, I've been avoiding double indentation, but maybe it's reasonable here? I'll have to see what everyone else says. For 3, I agree that moving the |
All sounds reasonable to me. I'll try and get a trial branch out this week to see how it looks when run on real code (maybe with point 2 applied for now), and then we can see if people are happy with it |
So, I've got an initial implementation in #335 which follows the WIP text above. The only thing thats missing now is a nice handling when comments are present within the expression (such as the code snippet in OP as well as in #321). I'll take a stab at this over the weekend hopefully. I don't really have a lot of real-world code using if expression syntax, so I don't have much to test with. I'd appreciate it if some people could try running #335 over a codebase whenever they've got some spare time, and reporting anything which seems weird! |
Ok. The style guide has been updated. For the multiline condition, we ended up saying "don't do that." So for Stylua, it wouldn't technically be against the style guide whichever format you went with. I don't think we really reached any agreement over double indent or not, but I don't think anyone thought it was unreasonable. |
#286 will add support for IfExpression syntax, but we currently just leave it be for the time being.
Need to decide the best formatting for if expression syntaxes.
Some examples:
I think something like this could work:
The text was updated successfully, but these errors were encountered: