EmmyLuaCodeStyle
EmmyLuaCodeStyle copied to clipboard
Feature Request: Alignment of multiline operator expressions
Sorry about spamming feature request lately! But I'm happy I've found a Lua-formatter/style checker that works for most of my needs! Here's something I do with my code often, and I wonder if this could be added as some kind of rule. I tend to align multiline statements that start with operators and here's the different usecases I do them:
Alignment in if-statements:
-- NOTE: Alignment of the first line in if statements that have multilines that begin with an operator.
-- The first expression is aligned with the first non-operator on the next line and so forth.
-- the operators are aligned too. note that "then" closes the if on multiline statements and is on it's first line
-- aligned with the "if":
if true and true
or false and false
or true
then
print("Yay!")
end
-- NOTE: A case where one of the preceding operators is longer than others:
if true and true
or false and false
not true
then
print("Yay!")
end
Aligment on multine expressions inside brackets (and for example in a return).
-- NOTE: The first expression is aligned according to the first non-operator below it and so forth:
function foo()
return (
100
* 123
+ 456
)
end
And lastly in assigment where there's a hanging "="-sign:
package.path
= "./?.lua;./?/init.lua;"
.. "./src/?.lua;./src/?/init.lua;"
.. "./lib/?.lua;./lib/?/init.lua;"
.. "./spec/?.lua;./spec/?/init.lua;"
.. package.path
-- NOTE: Alternatively this:
package.path =
"./?.lua;./?/init.lua;"
.. "./src/?.lua;./src/?/init.lua;"
.. "./lib/?.lua;./lib/?/init.lua;"
.. "./spec/?.lua;./spec/?/init.lua;"
.. package.path
I understand if these are out of the scope for this stylechecker/formatter, but I tend to use these in a lot of my codebases and would really enjoy having them covered, but I understand if there are some tricky cornercases that make these difficult to implement!