on master help sign in
add textobject queries for elixir
bcafdf4Michael Davis
book/src/generated/lang-support.md+1−1
@@ -15,7 +15,7 @@
15| edoc | ✓ | | | |
15| edoc | ✓ | | | |
16| eex | ✓ | | | |
16| eex | ✓ | | | |
17| ejs | ✓ | | | |
17| ejs | ✓ | | | |
18−| elixir | ✓ | | | `elixir-ls` |
18+| elixir | ✓ | ✓ | | `elixir-ls` |
19| elm | ✓ | | | `elm-language-server` |
19| elm | ✓ | | | `elm-language-server` |
20| erb | ✓ | | | |
20| erb | ✓ | | | |
21| erlang | ✓ | ✓ | | `erlang_ls` |
21| erlang | ✓ | ✓ | | `erlang_ls` |
runtime/queries/elixir/textobjects.scmnew file+27
@@ -0,0 +1,27 @@
1+; Function heads and guards have no body at all, so `keywords` and `do_block` nodes are both optional
2+((call
3+ target: (identifier) @_keyword
4+ (arguments
5+ [
6+ (call
7+ (arguments (_)? @parameter.inside))
8+ ; function has a guard
9+ (binary_operator
10+ left:
11+ (call
12+ (arguments (_)? @parameter.inside)))
13+ ]
14+ ; body is "do: body" instead of a do-block
15+ (keywords
16+ (pair
17+ value: (_) @function.inside))?)?
18+ (do_block (_)* @function.inside)?)
19+ (#match? @_keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp|test|describe|setup)$")) @function.around
20+
21+(anonymous_function
22+ (stab_clause right: (body) @function.inside)) @function.around
23+
24+((call
25+ target: (identifier) @_keyword
26+ (do_block (_)* @class.inside))
27+ (#match? @_keyword "^(defmodule|defprotocol|defimpl)$")) @class.around