-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
add textobject queries for beam languages, capture rust closures as functions #2661
add textobject queries for beam languages, capture rust closures as functions #2661
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't realized textobjects is specifically used for this. Looks good to me although I didn't check closely.
Since this is Elixir/Erlang-specific @connorlay, wdyt? 😀 I imagine the issue could be that clauses aren't always defined next to each other |
5a9bff3
to
ba4bab6
Compare
Elixir supports multiple function heads like this: def foo(:bar) do
"bar"
end
def foo(:baz) do
"baz"
end ...which I would consider two separate textobjects. However, if written as an anonymous function with multiple clauses like this: foo = fn
:bar -> "bar"
:baz -> "baz"
end I would consider that one textobject. Does that make sense @the-mikedavis @archseer ? |
ba4bab6
to
fd86411
Compare
I added queries for anonymous functions as well, so: fn
:ok -> 1
:error -> 2
end
We could probably do the same for rust closures, eh? |
Yup! |
Closures like iter.map(|a| a + 1) Are sort-of functions, so `]f` or `maf` or `mif` can apply to them as well as named function definitions.
Adds textobject queries for Erlang, Elixir & Gleam
Also includes an update for tree-sitter-erlang that makes
function_clause
a named node.Erlang and Elixir may have multiple function clauses for one function:
In these queries I'm capturing function clauses as
function.around
but I'm curious if others think it should be around the entire function definition.