meain / evil-textobj-tree-sitter

Tree-sitter powered textobjects for evil mode in Emacs
Apache License 2.0
191 stars 14 forks source link

Override `node` with `node.start` if available #39

Open meain opened 2 years ago

meain commented 2 years ago

We have a few nodes which could have overriding definitions in the same match (example). We have to override the inner one with .start one if this is present.

(decorated_definition
  (function_definition) @function.outer) @function.outer.start

In the above case, we have to use function.outer if function.outer.start is not available, but the latter otherwise and ignore function.outer. We have to remove the first one as otherwise we will have two starts for the same function.

@function.outer.start are optional decorations for the textobject like doctrings or template declarations. They will be added to the textobject range if present.

meain commented 2 years ago

Latest commit has also seems to have introduced things like function.end which gets combined optionally in ruby:

((method . name: (identifier) (method_parameters)? . (_) @function.inner (_)? @function.end .)
   (#make-range! "function.inner" @function.inner @function.end)) @function.outer
 ((singleton_method . name: (identifier) (method_parameters)? . (_) @function.inner (_)? @function.end .)
   (#make-range! "function.inner" @function.inner @function.end)) @function.outer

https://github.com/nvim-treesitter/nvim-treesitter-textobjects/commit/abaacefb1cde1e0d78e54194171c7981933a1849