feat: added mini.ai for better text objects

This commit is contained in:
Folke Lemaitre
2023-01-04 12:39:11 +01:00
parent c7d302eaac
commit 9907695320

View File

@ -122,4 +122,36 @@ return {
})
end,
},
-- better text-objects
{
"echasnovski/mini.ai",
keys = {
{ "a", mode = { "x", "o" } },
{ "i", mode = { "x", "o" } },
},
dependencies = {
{
"nvim-treesitter/nvim-treesitter-textobjects",
init = function()
-- no need to load the plugin, since we only need its queries
require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects")
end,
},
},
config = function()
local ai = require("mini.ai")
ai.setup({
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" }, {}),
},
})
end,
},
}