diff --git a/queries/elixir/textobjects.scm b/queries/elixir/textobjects.scm index e81a2a91..a91a87a6 100644 --- a/queries/elixir/textobjects.scm +++ b/queries/elixir/textobjects.scm @@ -28,12 +28,29 @@ (do_block "do" . (_) @class.inner . "end") ) @class.outer -; Function, Parameter, and Call Objects +; Parameters +(call + target: ((identifier) @_identifier (#any-of? @_identifier + "def" + "defmacro" + "defmacrop" + "defn" + "defnp" + "defp" + )) + (arguments (call [ + (arguments (_) @parameter.inner . "," @_delimiter) + (arguments ((_) @parameter.inner) @_delimiter .) + ] (#make-range! "parameter.outer" @parameter.inner @_delimiter))) +) @function.outer + +; Function and Call Objects (anonymous_function (stab_clause right: (body) @function.inner) ) @function.outer +; single child (call target: ((identifier) @_identifier (#any-of? @_identifier "def" @@ -43,17 +60,26 @@ "defnp" "defp" )) - (arguments (call [ - (arguments (_) @parameter.inner . "," @_delimiter) - (arguments ((_) @parameter.inner) @_delimiter .) - ] (#make-range! "parameter.outer" @parameter.inner @_delimiter))) - [ - (do_block "do" . (_) @_do (_) @_end . "end") - (do_block "do" . ((_) @_do) @_end . "end") - ] + (arguments (call)) + (do_block "do" . (_) @function.inner . "end") +) @function.outer + +; multi child +(call + target: ((identifier) @_identifier (#any-of? @_identifier + "def" + "defmacro" + "defmacrop" + "defn" + "defnp" + "defp" + )) + (arguments (call)) + (do_block "do" . (_) @_do (_) @_end . "end") (#make-range! "function.inner" @_do @_end) ) @function.outer +; def function(), do: .... (call target: ((identifier) @_identifier (#any-of? @_identifier "def" @@ -63,10 +89,8 @@ "defnp" "defp" )) - (arguments (call [ - (arguments (_) @parameter.inner . "," @_delimiter) - (arguments ((_) @parameter.inner) @_delimiter .) - ] (#make-range! "parameter.outer" @parameter.inner @_delimiter)) + (arguments + (call) (keywords (pair value: (_) @function.inner))