kickstart.nvim icon indicating copy to clipboard operation
kickstart.nvim copied to clipboard

Mention: Mini.ai treesitter textobjects

Open DerpDays opened this issue 11 months ago • 1 comments

It may be worthwhile to put a comment mentioning that mini.ai supports using treesitter text objects from nvim-treesitter-textobjects since it is easy to accidentally skip/not notice it has support for this.

Here's an example on how this looks (along with registering the objects with which key so they're easier to find) from my config

    {
        -- Better Around/Inside textobjects
        --
        -- Examples:
        --  - va)  - [V]isually select [A]round [)]parenthen
        --  - yinq - [Y]ank [I]nside [N]ext [']quote
        --  - ci'  - [C]hange [I]nside [']quote
        
        "echasnovski/mini.ai",
        dependencies = {
            "nvim-treesitter/nvim-treesitter-textobjects",
            "folke/which-key.nvim",
        },
        event = "VeryLazy",
        config = function()
            local wk = require("which-key")
            local spec_treesitter = require("mini.ai").gen_spec.treesitter
            require("mini.ai").setup {
                n_lines = 1000,
                custom_textobjects = {
                    a = spec_treesitter {
                        a = "@parameter.outer",
                        i = "@parameter.inner",
                    },
                    f = spec_treesitter {
                        a = "@function.outer",
                        i = "@function.inner",
                    },
                    o = spec_treesitter {
                        a = { "@conditional.outer", "@loop.outer" },
                        i = { "@conditional.inner", "@loop.inner" },
                    },
                    c = spec_treesitter {
                        a = { "@class.outer" },
                        i = { "@class.inner" },
                    },
                },
            }
            wk.register({
                ["aa"] = [[around parameter]],
                ["ia"] = [[inside parameter]],
                ["af"] = [[around function]],
                ["if"] = [[inside function]],
                ["ao"] = [[around condition/loop]],
                ["io"] = [[inside condition/loop]],
                ["ac"] = [[around class]],
                ["ic"] = [[inside class]],
            }, { mode = "o", prefix = "", preset = true })
        end,
    },

DerpDays avatar Mar 08 '24 06:03 DerpDays

I like this idea generally but I also think we need to strike a balance between not overwhelming new users while also inviting them to extend the kickstart for their own needs.

I'd suggest that if you feel strongly about this that please craft a PR with the documentation change you think makes sense and we can evaluate it more fully there.

feoh avatar Mar 12 '24 21:03 feoh

I think mentioning that there are more plugins to check out is a good way for them to go explore the rest of mini.nvim (there are a LOT of useful plugins there, but too many for someone just starting out).

Thanks for the suggestion tho :)

tjdevries avatar Mar 15 '24 14:03 tjdevries