diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 39e14fb3..80c3d454 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -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, + }, }