Skip to content

Handling empty anonymous functions #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
giddie opened this issue Dec 8, 2024 · 1 comment · Fixed by #78
Closed

Handling empty anonymous functions #77

giddie opened this issue Dec 8, 2024 · 1 comment · Fixed by #78

Comments

@giddie
Copy link

giddie commented Dec 8, 2024

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.

@giddie
Copy link
Author

giddie commented Dec 10, 2024

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
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant