Skip to content

Handling empty anonymous functions #77

Closed
@giddie

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.

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