Open amano-kenji opened 7 months ago
I investigated a bit with a smaller example.
With:
(setq lua-indent-level 2)
(setq lua-indent-nested-block-content-align nil)
and starting with the sample code:
fun("sample", function (a, b)
print("hi")
end)
and point at the beginning of the second line (the one that starts with text print("hi")
.
The result was:
fun("sample", function (a, b)
print("hi")
end)
The result was an indentation by 4 spaces here and I think the expectation is that it should be 2 spaces.
I think this reproduces the reported behavior.
I tried tracing execution of lua-indent-line
with edebug to see why the result was 4
.
Roughly the overall flow appears to be:
lua-indent-line
lua-calculate-indentation
-> 4
lua-calculate-indentation-block-modifier
-> 4
lua-accumulate-indentation-info
-> (absolute . 4)
lua-accumulate-indentation-info
-> ((relative . 2) (relative . 2) (absolute . 0))
I don't understand the details, but perhaps the above helps a bit with investigation (^^;
Also, this issue looked somewhat similar.
FWIW, I used Emacs 29.2 and it appears I'm using d074e413 of lua-mode
.
That's because function (a, b)
adds two spaces to the indentation on top of fun
which adds two spaces.
In emacs lua mode, indentation adds up. Indentation should not add up.
neovim lua mode prefers
emacs lua mode gives me
although lua indent level is 2. It is giving me the indent level of 4.