From cb737a55730ae5bc0d9b0f79922331f010387a89 Mon Sep 17 00:00:00 2001 From: Pratik Tripathy Date: Mon, 31 Mar 2025 11:31:16 +0530 Subject: [PATCH] feat(nvim-mini): Replace nvim-surround with nvim-surround & better comments for textobject selection with examples --- .../.config/nvim/lua/plugins/code-generic.lua | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/common/.config/nvim/lua/plugins/code-generic.lua b/common/.config/nvim/lua/plugins/code-generic.lua index a72c5d8..b1eee18 100644 --- a/common/.config/nvim/lua/plugins/code-generic.lua +++ b/common/.config/nvim/lua/plugins/code-generic.lua @@ -112,30 +112,42 @@ return { main = "ibl", }, - -- Tpope's surround but faster and in lua - { - "kylechui/nvim-surround", - version = "*", -- Use for stability; omit to use `main` branch for the latest features - event = "VeryLazy", - config = function() - -- Configuration here, or leave empty to use defaults - require("nvim-surround").setup({}) - end, - }, - -- mini.nvim: Collection of various small independent plugins/modules { "echasnovski/mini.nvim", version = false, config = function() - -- Better Around/Inside textobjects + -- va) - [V]isually select [A]round [)]paren + -- - a) would implicitly select around another ), based on some predefined logic + -- ci' - [C]hange [I]nside [']quote + -- via - [a]rguments + -- vif - [f]unction calls + -- va_ - Select around "_" + -- va1 - Select around two "1" -- - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [Q]uote - -- - ci' - [C]hange [I]nside [']quote - -- TODO: Learn about the other mini textobjects + -- Explicit Covering Region: + -- vinq - Select [I]nside [N]ext [Q]uote + -- vilb - Select Inside Last Bracket + -- cina - Change next function argument + -- cila - Change last function argument require("mini.ai").setup({ n_lines = 500 }) + -- mini.surround + -- Functionality similar to tpope's vim-surround + require("mini.surround").setup({ + mappings = { + add = "ys", -- Add surrounding in Normal and Visual modes + delete = "ds", -- Delete surrounding + find = "yf", -- Find surrounding (to the right) + find_left = "yF", -- Find surrounding (to the left) + highlight = "yh", -- Highlight surrounding + replace = "cs", -- Replace surrounding + update_n_lines = "", -- Update `n_lines` + }, + n_lines = 20, + search_method = "cover_or_next", + }) + -- gc require("mini.comment").setup()