From 081881b714e83bf4330e0a31991966cbf67d931a Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Fri, 28 Nov 2025 01:52:34 +0300 Subject: =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B0=D0=BF=D0=B4=D0=B5=D0=B9=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/nvim/lua/plugins/multicursor.lua | 76 +++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 config/nvim/lua/plugins/multicursor.lua (limited to 'config/nvim/lua/plugins/multicursor.lua') diff --git a/config/nvim/lua/plugins/multicursor.lua b/config/nvim/lua/plugins/multicursor.lua new file mode 100644 index 0000000..0a762a8 --- /dev/null +++ b/config/nvim/lua/plugins/multicursor.lua @@ -0,0 +1,76 @@ +return { + "jake-stewart/multicursor.nvim", + branch = "1.0", + config = function() + local mc = require("multicursor-nvim") + mc.setup() + + local set = vim.keymap.set + + -- Add or skip cursor above/below the main cursor. + set({ "n", "x" }, "", function() + mc.lineAddCursor(-1) + end ) + set({ "n", "x" }, "", function() + mc.lineAddCursor(1) + end ) + set({ "n", "x" }, "", function() + mc.lineSkipCursor(-1) + end) + set({ "n", "x" }, "", function() + mc.lineSkipCursor(1) + end) + + -- Add or skip adding a new cursor by matching word/selection + set({ "n", "x" }, "n", function() + mc.matchAddCursor(1) + end) + set({ "n", "x" }, "s", function() + mc.matchSkipCursor(1) + end) + set({ "n", "x" }, "N", function() + mc.matchAddCursor(-1) + end) + set({ "n", "x" }, "S", function() + mc.matchSkipCursor(-1) + end) + + -- Add and remove cursors with control + left click. + set("n", "", mc.handleMouse) + set("n", "", mc.handleMouseDrag) + set("n", "", mc.handleMouseRelease) + + -- Disable and enable cursors. + set({ "n", "x" }, "", mc.toggleCursor) + + -- Mappings defined in a keymap layer only apply when there are + -- multiple cursors. This lets you have overlapping mappings. + mc.addKeymapLayer(function(layerSet) + -- Select a different cursor as the main one. + layerSet({ "n", "x" }, "", mc.prevCursor) + layerSet({ "n", "x" }, "", mc.nextCursor) + + -- Delete the main cursor. + layerSet({ "n", "x" }, "x", mc.deleteCursor) + + -- Enable and clear cursors using escape. + layerSet("n", "", function() + if not mc.cursorsEnabled() then + mc.enableCursors() + else + mc.clearCursors() + end + end) + end) + + -- Customize how cursors look. + local hl = vim.api.nvim_set_hl + hl(0, "MultiCursorCursor", { reverse = true }) + hl(0, "MultiCursorVisual", { link = "Visual" }) + hl(0, "MultiCursorSign", { link = "SignColumn" }) + hl(0, "MultiCursorMatchPreview", { link = "Search" }) + hl(0, "MultiCursorDisabledCursor", { reverse = true }) + hl(0, "MultiCursorDisabledVisual", { link = "Visual" }) + hl(0, "MultiCursorDisabledSign", { link = "SignColumn" }) + end, +} -- cgit v1.2.3