on master help sign in
add textobject queries for elixir
commitbcafdf404fe22f61c9d2f0d883a6654a8a9b3ca3 authorMichael Davis <mcarsondavis@gmail.com> dateFri 3 Jun 2022, 09:26 (4 years ago) parent7a91474
2 files changed+28−1
book/src/generated/lang-support.md+1−1 runtime/queries/elixir/textobjects.scm+27
book/src/generated/lang-support.md+1−1
@@ -15,7 +15,7 @@
1515| edoc | ✓ | | | |
1616| eex | ✓ | | | |
1717| ejs | ✓ | | | |
18−| elixir | ✓ | | | `elixir-ls` |
18+| elixir | ✓ | ✓ | | `elixir-ls` |
1919| elm | ✓ | | | `elm-language-server` |
2020| erb | ✓ | | | |
2121| 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