Skip to content

mini.ai: use different search_method for treesitter textobjects? #1076

Closed Answered by echasnovski
Bvngee asked this question in Q&A
Discussion options

You must be logged in to vote

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 as find_textobject(), which in turn can be configured to use specific search method via opts.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:

local ai = require('mini.ai')
local spec_ts = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' })
local spec_ts_cover = function(a…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@Bvngee
Comment options

Answer selected by Bvngee
Comment options

You must be logged in to vote
3 replies
@Goose97
Comment options

@echasnovski
Comment options

@Goose97
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants
Converted from issue

This discussion was converted from issue #1075 on July 22, 2024 07:14.