From 8f47d35c4e373d437cf650ee2a88f0c7ae62acd2 Mon Sep 17 00:00:00 2001 From: Jeremy Kaplan Date: Sun, 19 Oct 2025 16:13:37 -0400 Subject: [PATCH] neovim: Auto-correct old bindings to standard ones --- neovim/init.lua | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/neovim/init.lua b/neovim/init.lua index 27bcc06..7920ae5 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -76,16 +76,6 @@ vim.keymap.set("", "w", "", { remap = true }) vim.keymap.set("", 'w"', ":split") vim.keymap.set("", 'w%', ":vsplit") --- TODO: Delete these ; fake-leader bindings -vim.keymap.set("", ";h", ":wincmd h") -vim.keymap.set("", ";j", ":wincmd j") -vim.keymap.set("", ";k", ":wincmd k") -vim.keymap.set("", ";l", ":wincmd l") - -vim.keymap.set("", ';"', ":split") -vim.keymap.set("", ';%', ":vsplit") -vim.keymap.set("", ';0', ":close") - vim.keymap.set("", 'w', ":w") vim.keymap.set("n", "]", function() @@ -143,3 +133,22 @@ vim.keymap.set("n", "", function() end) vim.diagnostic.config({ jump = { float = true } }) + +function auto_correct(mode, old, new, scale, limit, cmd) + delay = scale + + vim.keymap.set(mode, old, function() + vim.print("You should use " .. new) + vim.cmd.sleep(delay .. "m") + cmd() + delay = math.min(delay + scale, limit) + end) +end + +auto_correct("n", ';"', 's', 100, 1000, vim.cmd.split) +auto_correct("n", ';%', 'v', 100, 1000, vim.cmd.vsplit) +auto_correct("n", ';0', 'c', 100, 1000, vim.cmd.close) +auto_correct("n", ";h", "h", 10, 500, function() vim.cmd.wincmd("h") end) +auto_correct("n", ";j", "j", 10, 500, function() vim.cmd.wincmd("j") end) +auto_correct("n", ";k", "k", 10, 500, function() vim.cmd.wincmd("k") end) +auto_correct("n", ";l", "l", 10, 500, function() vim.cmd.wincmd("l") end)