mini.ai: use different search_method for treesitter textobjects? #1076
-
I apologize if this question has already been answered or explained elsewhere that I could not find. In most cases, I think PS. I absolutely love what you're doing with mini.nvim, thanks for the awesome work <3 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I don't think this was answered before, so no need to apologize :) Although not straightforward, there is a way to do this. The So the solution here would be to wrap the output of local ai = require('mini.ai')
local spec_ts = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' })
local spec_ts_cover = function(ai_type, id, opts)
opts.search_method = 'cover'
return spec_ts(ai_type, id, opts)
end
ai.setup({
custom_textobjects = {
F = spec_ts_cover,
},
}) That said, my recommendation would be to use |
Beta Was this translation helpful? Give feedback.
-
Sorry for resurrect this thread. I want to achieve the same thing but for brackets ((, [, {). I want the bracket to always use the
One solution I can think of is to increase the size of Thanks for this module. I think the API is well thought-out and the documentation is superb. |
Beta Was this translation helpful? Give feedback.
I don't think this was answered before, so no need to apologize :)
Although not straightforward, there is a way to do this. The
gen_spec.treesitter()
function returns a callable (i.e. function) specification. This returned function has the same signature asfind_textobject()
, which in turn can be configured to use specific search method viaopts.search_method
.So the solution here would be to wrap the output of
gen_spec.treesitter()
in own function which forces specific search method. Here is an example for "function definition" textobject: