Skip to content

Incorrect indentation. #213

Open
Open

Description

@amano-kenji

neovim lua mode prefers

node_om:connect("object-added", function (node_om, node)
  -- If the node is added, print update.
  print("update")
  node:connect("params-changed", function (node, paramId)
    -- If the node's parameters changed, print update.
    print("update")
  end)
end)

emacs lua mode gives me

node_om:connect("object-added", function (node_om, node)
    -- If the node is added, print update.
    print("update")
    node:connect("params-changed", function (node, paramId)
        -- If the node's parameters changed, print update.
        print("update")
    end)
end)

although lua indent level is 2. It is giving me the indent level of 4.

Activity

  1. sogaiu commented on Feb 23, 2024

    @sogaiu

    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:

    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 d074e41 of lua-mode.

  2. amano-kenji commented on Feb 24, 2024

    @amano-kenji
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions