From bcafdf404fe22f61c9d2f0d883a6654a8a9b3ca3 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 3 Jun 2022 09:26:48 -0500 Subject: add textobject queries for elixir --- runtime/queries/elixir/textobjects.scm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 runtime/queries/elixir/textobjects.scm (limited to 'runtime/queries') 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 -- cgit v1.2.3-70-g09d2