From 3bb4ec6ec4d5d4adaf15d22899788c3db407bdad Mon Sep 17 00:00:00 2001 From: steven-na Date: Tue, 30 Jun 2026 19:55:05 -0700 Subject: 2 different vim versions --- arch/lightvim/.config/lightvim/lua/plugins.lua | 128 ++++++++++++++----------- 1 file changed, 73 insertions(+), 55 deletions(-) (limited to 'arch/lightvim/.config') diff --git a/arch/lightvim/.config/lightvim/lua/plugins.lua b/arch/lightvim/.config/lightvim/lua/plugins.lua index d9b563b..2f737b2 100644 --- a/arch/lightvim/.config/lightvim/lua/plugins.lua +++ b/arch/lightvim/.config/lightvim/lua/plugins.lua @@ -102,64 +102,82 @@ return { config = function() local mc = require("multicursor-nvim") mc.setup() - local set = vim.keymap.set local nv = { "n", "v" } - -- Adding cursors (Alt+Shift+arrow — Ctrl+Shift+arrow is move-line) - set(nv, "", function() mc.lineAddCursor(1) end, { desc = "Add cursor down" }) - set(nv, "", function() mc.lineAddCursor(-1) end, { desc = "Add cursor up" }) - - -- Skipping (advance without dropping a cursor) - set(nv, "m", function() mc.lineSkipCursor(1) end, { desc = "Skip line down" }) - set(nv, "m", function() mc.lineSkipCursor(-1) end, { desc = "Skip line up" }) - - -- Match-based add / skip - set(nv, "mn", function() mc.matchAddCursor(1) end, { desc = "Add cursor: next match" }) - set(nv, "mp", function() mc.matchAddCursor(-1) end, { desc = "Add cursor: prev match" }) - set(nv, "ms", function() mc.matchSkipCursor(1) end, { desc = "Skip match, advance" }) - set(nv, "mA", mc.matchAllAddCursors, { desc = "Cursors for all matches" }) - - -- Repeat keys: ;/, add or skip when cursors active; default f/F/t/T otherwise - set("n", ";", function() - if mc.hasCursors() then mc.matchAddCursor(1) else vim.cmd("normal! ;") end - end, { desc = "Repeat f/F/t/T · next-match cursor when active" }) - set("n", ",", function() - if mc.hasCursors() then mc.matchSkipCursor(1) else vim.cmd("normal! ,") end - end, { desc = "Reverse f/F/t/T · skip-match when active" }) - - -- Manual toggle / delete - set(nv, "mt", mc.toggleCursor, { desc = "Toggle cursor here" }) - set(nv, "mx", mc.deleteCursor, { desc = "Delete cursor under main" }) - - -- Rotate / jump main focus through cursor list (arrows) - set(nv, "m", mc.nextCursor, { desc = "Rotate to next cursor" }) - set(nv, "m", mc.prevCursor, { desc = "Rotate to prev cursor" }) - set(nv, "mF", mc.firstCursor, { desc = "Jump to first cursor" }) - set(nv, "mL", mc.lastCursor, { desc = "Jump to last cursor" }) - - -- Bulk ops - set(nv, "m=", mc.alignCursors, { desc = "Align cursors" }) - set(nv, "mu", mc.restoreCursors, { desc = "Restore last cursors" }) - set(nv, "md", function() - if mc.cursorsEnabled() then mc.disableCursors() else mc.enableCursors() end - end, { desc = "Freeze/unfreeze cursors" }) - set(nv, "m.", function() mc.transposeCursors(1) end, { desc = "Transpose forward" }) - set(nv, "m,", function() mc.transposeCursors(-1) end, { desc = "Transpose back" }) - - -- Pattern-based (visual mode — needs a selection) - set("x", "m/", mc.matchCursors, { desc = "Cursors at regex matches" }) - set("x", "mS", mc.splitCursors, { desc = "Split selection by pattern" }) - - -- Esc: re-enable / clear / nohlsearch - set("n", "", function() - if not mc.cursorsEnabled() then - mc.enableCursors() - elseif mc.hasCursors() then - mc.clearCursors() - else - vim.cmd("nohlsearch") + -- Bind everything via a function so we can re-apply per-buffer + -- (oil buffers set their own buffer-local maps that would otherwise + -- shadow these globals). + local function bind(buf) + local opts_base = buf and { buffer = buf } or {} + local function set(mode, lhs, rhs, opts) + local o = vim.tbl_extend("force", opts_base, opts or {}) + vim.keymap.set(mode, lhs, rhs, o) end - end) + + -- Adding cursors (Alt+Shift+arrow — Ctrl+Shift+arrow is move-line) + set(nv, "", function() mc.lineAddCursor(1) end, { desc = "Add cursor down" }) + set(nv, "", function() mc.lineAddCursor(-1) end, { desc = "Add cursor up" }) + + -- Skipping (advance without dropping a cursor) + set(nv, "m", function() mc.lineSkipCursor(1) end, { desc = "Skip line down" }) + set(nv, "m", function() mc.lineSkipCursor(-1) end, { desc = "Skip line up" }) + + -- Match-based add / skip + set(nv, "mn", function() mc.matchAddCursor(1) end, { desc = "Add cursor: next match" }) + set(nv, "mp", function() mc.matchAddCursor(-1) end, { desc = "Add cursor: prev match" }) + set(nv, "ms", function() mc.matchSkipCursor(1) end, { desc = "Skip match, advance" }) + set(nv, "mA", mc.matchAllAddCursors, { desc = "Cursors for all matches" }) + + -- Repeat keys: ;/, add or skip when cursors active; default f/F/t/T otherwise + set("n", ";", function() + if mc.hasCursors() then mc.matchAddCursor(1) else vim.cmd("normal! ;") end + end, { desc = "Repeat f/F/t/T · next-match cursor when active" }) + set("n", ",", function() + if mc.hasCursors() then mc.matchSkipCursor(1) else vim.cmd("normal! ,") end + end, { desc = "Reverse f/F/t/T · skip-match when active" }) + + -- Manual toggle / delete + set(nv, "mt", mc.toggleCursor, { desc = "Toggle cursor here" }) + set(nv, "mx", mc.deleteCursor, { desc = "Delete cursor under main" }) + + -- Rotate / jump main focus through cursor list (arrows) + set(nv, "m", mc.nextCursor, { desc = "Rotate to next cursor" }) + set(nv, "m", mc.prevCursor, { desc = "Rotate to prev cursor" }) + set(nv, "mF", mc.firstCursor, { desc = "Jump to first cursor" }) + set(nv, "mL", mc.lastCursor, { desc = "Jump to last cursor" }) + + -- Bulk ops + set(nv, "m=", mc.alignCursors, { desc = "Align cursors" }) + set(nv, "mu", mc.restoreCursors, { desc = "Restore last cursors" }) + set(nv, "md", function() + if mc.cursorsEnabled() then mc.disableCursors() else mc.enableCursors() end + end, { desc = "Freeze/unfreeze cursors" }) + set(nv, "m.", function() mc.transposeCursors(1) end, { desc = "Transpose forward" }) + set(nv, "m,", function() mc.transposeCursors(-1) end, { desc = "Transpose back" }) + + -- Pattern-based (visual mode — needs a selection) + set("x", "m/", mc.matchCursors, { desc = "Cursors at regex matches" }) + set("x", "mS", mc.splitCursors, { desc = "Split selection by pattern" }) + + -- Esc: re-enable / clear / nohlsearch + set("n", "", function() + if not mc.cursorsEnabled() then + mc.enableCursors() + elseif mc.hasCursors() then + mc.clearCursors() + else + vim.cmd("nohlsearch") + end + end) + end + + bind(nil) + + -- Re-bind buffer-local for oil so its keymaps don't shadow ours. + vim.api.nvim_create_autocmd("FileType", { + pattern = "oil", + callback = function(args) bind(args.buf) end, + }) end, }, -- cgit v1.2.3