From fd7becb4132bab74a9c216144bd6d52c787c74d8 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Sun, 17 Dec 2023 17:28:40 +0000 Subject: [PATCH] nvim: make MiniSurround behave more like tpope/surround --- nvim/lua/plugins/coding.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/nvim/lua/plugins/coding.lua b/nvim/lua/plugins/coding.lua index 7bf442f..bda4a98 100644 --- a/nvim/lua/plugins/coding.lua +++ b/nvim/lua/plugins/coding.lua @@ -92,10 +92,16 @@ return { -- surround { "echasnovski/mini.surround", - keys = { - { "S", "lua MiniSurround.add('visual')", "x" }, - { "yss", "ys_", remap = true }, - }, + keys = function() + -- HACK: use function to disable merging with LazyVim's keys definition + return { + { "ys", desc = "Add surrounding", "n" }, + { "S", desc = "Add surrounding", "x" }, + { "ds", desc = "Delete surrounding" }, + { "cs", desc = "Change surrounding" }, + { "yss", "ys_", remap = true }, + } + end, opts = { mappings = { -- TODO: this is tpope/surround like, but should consider using vim-sandwich mappings @@ -109,6 +115,12 @@ return { update_n_lines = "", }, }, + config = function(_, opts) + require("mini.surround").setup(opts) + -- remap visual + vim.keymap.del("x", "ys", { silent = true }) + vim.keymap.set("x", "S", [[:lua MiniSurround.add('visual')]], { silent = true }) + end, }, -- comments { -- 2.48.1