Skip to content

Handling empty anonymous functions #77

Closed

Description

@giddie

I've been trying to work around this issue that when writing anonymous functions, treesitter-based indentation (in Neovim) always trips up if there are no clauses:

    enum = [1, 2, 3]
    Enum.map(enum, fn   # Typing <CR> here takes the cursor to the left margin.
|
end)

Re-applying indentation to these lines causes them all to jump to the left margin.

The issue seems to be that there's an ERROR node there, because an fn end without clauses is not well-formed Elixir. But it would be really handy if the treesitter grammar could accept this as an anonymous function, because it's certainly a common enough shape for the code to be in before clauses are added. My hope is that if the grammar can accept this as an anonymous function, indentation will follow suit.

Activity

  1. giddie commented on Dec 10, 2024

    @giddie
    Author

    Thank you so much for the fast turnaround! You guys are awesome 🥳 🍻

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions