Skip to content

Commit

Permalink
add textobject queries for elixir
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Jun 6, 2022
1 parent 2e87827 commit 5efe467
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
| edoc || | | |
| eex || | | |
| ejs || | | |
| elixir || | | `elixir-ls` |
| elixir || | | `elixir-ls` |
| elm || | | `elm-language-server` |
| erb || | | |
| erlang ||| | `erlang_ls` |
Expand Down
27 changes: 27 additions & 0 deletions runtime/queries/elixir/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
; Function heads and guards have no body at all, so `keywords` and `do_block` nodes are both optional
((call
target: (identifier) @_keyword
(arguments
[
(call
(arguments (_)? @parameter.inside))
; function has a guard
(binary_operator
left:
(call
(arguments (_)? @parameter.inside)))
]
; body is "do: body" instead of a do-block
(keywords
(pair
value: (_) @function.inside))?)?
(do_block (_)* @function.inside)?)
(#match? @_keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp|test|describe|setup)$")) @function.around

(anonymous_function
(stab_clause right: (body) @function.inside)) @function.around

((call
target: (identifier) @_keyword
(do_block (_)* @class.inside))
(#match? @_keyword "^(defmodule|defprotocol|defimpl)$")) @class.around

0 comments on commit 5efe467

Please sign in to comment.