Custom text object not working #1561
-
Contributing guidelines
Module(s)mini.ai QuestionI was using custom text objects that I copied from lazyvim a while ago and for a long time, it has been working until recently after I updated my plugins, one of the custom text object which I use frequently use no longer works. opts = function()
local ai = require("mini.ai")
return {
n_lines = 500,
custom_textobjects = {
f = ai.gen_spec.treesitter({
a = "@function.outer",
i = "@function.inner",
}),
},
}
end I used my lazyvim setup and it was still working there, I checked if any changes was made in lazyvim but none was made and it is exactly the same as mine. I have nvim treesitter installed and also added it to the depencies, it wasn't there previously because treesitter loads at start up but because of this issue, I added it. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Now that i went back to this, all custom text objects with treesitter arent working. return {
"echasnovski/mini.ai",
event = "VeryLazy",
dependencies = { "nvim-treesitter/nvim-treesitter" },
opts = function()
local ai = require("mini.ai")
return {
n_lines = 500,
custom_textobjects = {
o = ai.gen_spec.treesitter({
a = { "@block.outer", "@conditional.outer", "@loop.outer" },
i = { "@block.inner", "@conditional.inner", "@loop.inner" },
}),
f = ai.gen_spec.treesitter({
a = "@function.outer",
i = "@function.inner",
}),
c = ai.gen_spec.treesitter({
a = "@class.outer",
i = "@class.inner",
}),
t = { "<([%p%w]-)%f[^<%w][^<>]->.-</%1>", "^<.->().*()</[^/]->$" },
d = { "%f[%d]%d+" }, -- digits
e = { -- Word with case
{
"%u[%l%d]+%f[^%l%d]",
"%f[%S][%l%d]+%f[^%l%d]",
"%f[%P][%l%d]+%f[^%l%d]",
"^[%l%d]+%f[^%l%d]",
},
"^().*()$",
},
u = ai.gen_spec.function_call(), -- u for "Usage"
U = ai.gen_spec.function_call({ name_pattern = "[%w_]" }), -- without dot in function name
},
}
end,
} |
Beta Was this translation helpful? Give feedback.
-
Tree-sitter textobjects in 'mini.ai' (and input surroundings in 'mini.surround', for that matter) require tree-sitter queries which define how specific captures should be computed. You can check more in this portion of the help. The easiest solution here is use 'nvim-treesitter/nvim-treesitter-textobjects' dependency. Using 'nvim-treesitter/nvim-treesitter' itself is not really necessary as textobject will fall back to the built-in I pretty sure this is the problem here. If you still don't have custom tree-sitter textobjects working after installing 'nvim-treesitter-textobjects', feel free to add more info here. |
Beta Was this translation helpful? Give feedback.
Tree-sitter textobjects in 'mini.ai' (and input surroundings in 'mini.surround', for that matter) require tree-sitter queries which define how specific captures should be computed. You can check more in this portion of the help.
The easiest solution here is use 'nvim-treesitter/nvim-treesitter-textobjects' dependency. Using 'nvim-treesitter/nvim-treesitter' itself is not really necessary as textobject will fall back to the built-in
vim.treesitter
usage (which should be on par with outer plugin at least since Neovim>=0.9).I pretty sure this is the problem here. If you still don't have custom tree-sitter textobjects working after installing 'nvim-treesitter-textobjects', feel free to add m…