From 2b0cd45de96a9839af9dcf40943b95c99ed457ce Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Mon, 18 May 2026 21:58:52 +0545 Subject: [PATCH] =?UTF-8?q?feat(lua):=20introduce=20context=E2=80=91aware?= =?UTF-8?q?=20paste=20mappings=20with=20auto=E2=80=91indent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - New Features: Added `p` and `P` mappings that auto‑indent pasted text (`p=`] and `P=`]). - Enhancements: Updated visual paste mapping to use `"_dP` for overwriting without affecting registers. - Bug Fixes: Fixed potential register corruption by using `"_dP` on selection. --- lua/keys.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/keys.lua b/lua/keys.lua index 61e733b..b5759a8 100644 --- a/lua/keys.lua +++ b/lua/keys.lua @@ -42,6 +42,10 @@ map({ 'n', 'v' }, 'L', '$', { desc = 'Move to the end of the line' }) -- Visual overwrite paste map({ 'v', 'x' }, 'p', '"_dP', opts) +-- Paste and auto-indent (context-aware) +map('n', 'p', 'p=`]', { desc = 'Paste and auto-indent' }) +map('n', 'P', 'P=`]', { desc = 'Paste before and auto-indent' }) + -- Do not copy on x map({ 'v', 'x' }, 'x', '"_x', opts) map('n', 'X', '"_D', opts)