-
Notifications
You must be signed in to change notification settings - Fork 76
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
Enhance indentation of blocks #151
Conversation
Hey, thank you for the contribution! It has docs, maintains backward compability, and the change is very focused and self-contained. Great stuff! Could you please add some tests to ensure this behaviour is not lost in any potential refactoring down the road? |
1068951
to
aee46da
Compare
I've also added E.g., With local foo = setmetatable( {
a = 4,
b = 5,
}, {
__index = some_func,
} ) With local foo = setmetatable( {
a = 4,
b = 5,
}, {
__index = some_func,
} ) |
Hey, awesome stuff with the tests, but I'm not sure if we need the |
The E.g., Default settings: call_some_fn( something, {
val = 5,
val = 7,
}, {
val = 6,
} ) With call_some_fn( something, {
val = 5,
val = 7,
}, {
val = 6,
} ) With call_some_fn( something, {
val = 5,
val = 7,
}, {
val = 6,
} ) With both call_some_fn( something, {
val = 5,
val = 7,
}, {
val = 6,
} ) |
Would you like me to combine |
Hmm... I think I missed one case here. My original idea stemmed from the fact that there could be different preferences w.r.t. where should the table content go:
But I couldn't find a reason for the closing brace to be anywhere else but at content indentation minus 1 indentation offset. This was about the case when there is no potential alignment inside the table, i.e. when the inside table elements start on the subsequent line,
But then your comment made me realize that there are still cases when the first element in the nested table is on the same row as the opening brace and it creates an alignment dilemma, so to speak, even without the outer function call: -- this looks fine
foo = {1,
2,
3}
-- but the following two look strange
foo = {1,
2,
3
}
foo = {1,
2,
3
}
-- although less strange than "minus one level of indentation"
foo = {1,
2,
3
} So I guess it would make sense to introduce a variable for people to "pick their poison" in cases when table elements are aligned, but the close brace is on a separate line. |
So are you saying to leave it as it is, so the user has the choice? 🤔 |
Sorry for the delay here. I'm going to merge it. Thank you for your work and for your patience! |
Hey! Looks like foobar(123,
456) In this example there are no nested blocks, but since alignment is disabled, 456 is indented instead. |
Added
lua-indent-nested-block-content-align
var, which disables the aligning of content of nested blocks to the opening brace and indents normally. It defaults tot
, which is the previous behaviour.E.g. 1:
With
lua-indent-nested-block-content-align
sett
(default), then:Wth
lua-indent-nested-block-content-align
setnil
, then:E.g. 2:
With
lua-indent-nested-block-content-align
sett
(default), then:Wth
lua-indent-nested-block-content-align
setnil
, then: