Skip to content

Conversation

@TheLeoP
Copy link
Contributor

@TheLeoP TheLeoP commented Sep 15, 2025

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:

At the moment I don't think I like the idea because it introduces issues about how the textobject should be searched. Like if there is a non-covering textobject with injected language and covering textobject for parent language, which one should be chosen with cover_or_next search method. I'd probably expect the former, but I can see how the latter can be expected.

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.

My current idea is to allow to specify "valid" languages for textobject. Then they can be adjusted specifically for filetype to query only expected parser. This has both upsides and downsides, which mostly are related to expected workflow and use cases. I'll take a look.

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?

@echasnovski
Copy link
Member

Let's go with #2010 approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants