diff options
author | Michael Davis | 2022-06-03 14:26:48 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-06-07 11:03:31 +0000 |
commit | bcafdf404fe22f61c9d2f0d883a6654a8a9b3ca3 (patch) | |
tree | b5367eec3d09cc6e46b3e5c3c7c61131a8b241cb | |
parent | 7a9147489e8c058561bb37834c791b027fb0b4ae (diff) |
add textobject queries for elixir
-rw-r--r-- | book/src/generated/lang-support.md | 2 | ||||
-rw-r--r-- | runtime/queries/elixir/textobjects.scm | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 8d8936ae..064438fd 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -15,7 +15,7 @@ | edoc | ✓ | | | | | eex | ✓ | | | | | ejs | ✓ | | | | -| elixir | ✓ | | | `elixir-ls` | +| elixir | ✓ | ✓ | | `elixir-ls` | | elm | ✓ | | | `elm-language-server` | | erb | ✓ | | | | | erlang | ✓ | ✓ | | `erlang_ls` | diff --git a/runtime/queries/elixir/textobjects.scm b/runtime/queries/elixir/textobjects.scm new file mode 100644 index 00000000..52a6f66d --- /dev/null +++ b/runtime/queries/elixir/textobjects.scm @@ -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 |