feat(ai): query all language_trees for textobjects #2009
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #2006
I open this as a draft because there isn't a consensus on how this should be handled. This PR queries all of the languages in the current buffer, which could lead to unwanted behavior (as mentioned in #2006 (comment)).
To address a few of the topics mentioned in that comment:
With this PR, the current heuristic for choosing between multiple regions is used (which may not be the desired behavior). There's no distinction between textobjects in injected and non-injected languages.
This would be an easy change. We could skip the language if it's not in the allow list for a specific filetype in
https://github.com/theleop/mini.nvim/blob/d647be34c34d03b71d7196be497eb2dfd2ebdab6/lua/mini/ai.lua#L1564
But, what would the default behavior be? Allow all languages? Only allow the language under cursor to keep the current behavior?