nvim-treesitter / nvim-treesitter-textobjects

Apache License 2.0
2.11k stars 190 forks source link

Allow multiple queries for `select` to increase configurability #555

Open mehalter opened 7 months ago

mehalter commented 7 months ago

Is your feature request related to a problem? Please describe. Some select text objects I don't want to map to their own individual keys and would rather just take the first one available from a list of queries.

Describe the solution you'd like Similar to the move and swap text objects, it would be amazing to supply regex or a list of queries to a select text object. That way we can bind several queries easily to a single keymap.

Describe alternatives you've considered I'm not sure if there is any other alternative other than just mapping each query to it's own mapping

Additional context I'm curious if there is an architectural limitation that kept this from being implemented in the first place when multiple query support was added to move and swap. Plugins like mini.ai have support for utilitizing the nvim-treesitter-textobjects queries to construct select mappings with multiple queries which leads me to believe it should be doable here as well.

Thanks so much for everyone's work here maintaining and developing this plugin, it is a godsend!

LJFRIESE commented 3 weeks ago

This is what mini.ai does. It uses a series of helper functions to facilitate iterating through the table of supplied node types. I would love to see this here as well.