nvim-treesitter-textobjects
nvim-treesitter-textobjects copied to clipboard
Motion around node
It would be very convenient to have in addition to init_selection a similar command that works in operator-pending mode, i.e., something like "around node" or "an", so that one can use "dan", "yan" etc.
Currently the same functionality can be done by first invoking the init_selection and then using the operator, but in my opinion around operator can be useful as well. There is also a treesitter-textobjects, that allows around motions, but only for selected tags in selected languages, whereas "around node" should be quite general.
I have tried to use the public api of treesitter to write this functionality, but failed, perhaps due to my lack of knowledge. If there is a way, maybe it can be added to the documentation, and if not I believe that this can easily be done using the inner workings of nvim-treesitter.
Maybe you would like this plugin: https://github.com/RRethy/nvim-treesitter-textsubjects
It could also be added as (_) @node to https://github.com/nvim-treesitter/nvim-treesitter-textobjects/ which would work on every language. I would like to move this issue to nvim-treesitter-textobjects as there we already have logic for selecting textobjects node-based.