From 15a7c2d8e005391d4aaac919b5776b5fa2822a41 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 14 Sep 2023 22:05:28 +0200 Subject: nvim: Preserve registers when transposing chars --- .config/nvim/lua/mango/lib.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to '.config/nvim/lua/mango/lib.lua') diff --git a/.config/nvim/lua/mango/lib.lua b/.config/nvim/lua/mango/lib.lua index 4c38986..9182a06 100644 --- a/.config/nvim/lua/mango/lib.lua +++ b/.config/nvim/lua/mango/lib.lua @@ -18,4 +18,20 @@ function M.remap(modes, from, to, opts) vim.keymap.set(ct, from, to, opts) end +function M.save_regs(regs, callback) + local rs = {} + for r in regs:gmatch('.') do + rs[r] = { + s = vim.fn.getreg(r), + t = vim.fn.getregtype(r), + } + end + + callback() + + for k, v in pairs(rs) do + vim.fn.setreg(k, v.s, v.t) + end +end + return M -- cgit v1.2.3