From 2e3970f1ef3103f8f0795474e5e24089a7ebc585 Mon Sep 17 00:00:00 2001 From: Mathias Schneider Date: Mon, 13 Apr 2026 11:42:44 +0200 Subject: [PATCH] fix: surround update --- term/.config/nvim/lua/plugins/surround.lua | 32 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/term/.config/nvim/lua/plugins/surround.lua b/term/.config/nvim/lua/plugins/surround.lua index 8c5b167..fb4f4d4 100644 --- a/term/.config/nvim/lua/plugins/surround.lua +++ b/term/.config/nvim/lua/plugins/surround.lua @@ -2,14 +2,34 @@ return { "kylechui/nvim-surround", version = "*", event = "VeryLazy", + init = function() + -- Disable default keymaps (we'll set custom ones) + vim.g.nvim_surround_no_mappings = true + end, config = function() require("nvim-surround").setup({ - keymaps = { - add = "S", -- Add surrounding - delete = "SD", -- Delete surrounding - change = "SC", -- Change surrounding - change_line = "SCL", -- Change surrounding on current line - }, + -- Configuration for surrounds, aliases, etc. can go here + }) + -- Set custom keymaps (v4 method) + -- Add surrounding: Siw" -> surround word with quotes, Siw) -> (surround word) + vim.keymap.set("n", "S", "(nvim-surround-normal)", { + desc = "Add surrounding", + }) + -- Delete surrounding: SD" -> remove quotes, SD) -> remove parentheses + vim.keymap.set("n", "SD", "(nvim-surround-delete)", { + desc = "Delete surrounding", + }) + -- Change surrounding: SC"' -> change quotes to single quotes, SC)] -> change parens to brackets + vim.keymap.set("n", "SC", "(nvim-surround-change)", { + desc = "Change surrounding", + }) + -- Change surrounding on current line + vim.keymap.set("n", "SCL", "(nvim-surround-change-line)", { + desc = "Change surrounding on current line", + }) + -- Visual mode: select text and press S" -> surround selection with quotes + vim.keymap.set("v", "S", "(nvim-surround-visual)", { + desc = "Add surrounding in visual mode", }) end, }