emacs-tree-sitter / elisp-tree-sitter

Emacs Lisp bindings for tree-sitter
https://emacs-tree-sitter.github.io
MIT License
822 stars 74 forks source link

How to create an evil text object for bash functions using emacs-tree-sitter? #147

Closed NightMachinery closed 3 years ago

NightMachinery commented 3 years ago

How to create an evil text object for bash functions using emacs-tree-sitter?

theHamsta commented 3 years ago

I have no idea on how to do that in emacs. But it would be great to team up and share queries as we have already a bunch of textobjects defined here for Neovim https://github.com/nvim-treesitter/nvim-treesitter-textobjects. In case anyone wants to start a similar project for emacs

ubolonton commented 3 years ago

This depends on the mechanism to define new text objects in evil. tree-sitter helps with locating the objects.

For a simple text object like a function, tree-sitter-node-at-point could be enough.

A more generic implementation could define interfaces to plug in language-specific text-object queries, like what @theHamsta mentioned above.