diff options
| author | Kyren223 <contact@kyren.codes> | 2026-09-29 23:28:11 +0300 |
|---|---|---|
| committer | Kyren223 <contact@kyren.codes> | 2026-09-29 23:28:11 +0300 |
| commit | 7efc13b5ceae88d67840a6b22ae758e500875173 (patch) | |
| tree | 577c46a90a29da42c5ff2a678de5f7d383115e04 | |
| parent | a37e3b832ee8b439cdd90382155688a347371d60 (diff) | |
Added multicursor plugin
| -rw-r--r-- | .config/nvim/lua/plugins/multicursor.lua | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/.config/nvim/lua/plugins/multicursor.lua b/.config/nvim/lua/plugins/multicursor.lua new file mode 100644 index 0000000..d4c6224 --- /dev/null +++ b/.config/nvim/lua/plugins/multicursor.lua @@ -0,0 +1,74 @@ +return { + 'jake-stewart/multicursor.nvim', + branch = '1.0', + event = 'VeryLazy', + 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' }, '<up>', function() + mc.lineAddCursor(-1) + end) + set({ 'n', 'x' }, '<down>', function() + mc.lineAddCursor(1) + end) + set({ 'n', 'x' }, '<leader><up>', function() + mc.lineSkipCursor(-1) + end) + set({ 'n', 'x' }, '<leader><down>', function() + mc.lineSkipCursor(1) + end) + + set({"n", "x"}, "<leader>A", mc.searchAllAddCursors) + + -- Add or skip adding a new cursor by matching word/selection + -- set({ 'n', 'x' }, '<leader>n', function() + -- mc.matchAddCursor(1) + -- end) + -- set({ 'n', 'x' }, '<leader>s', function() + -- mc.matchSkipCursor(1) + -- end) + -- set({ 'n', 'x' }, '<leader>N', function() + -- mc.matchAddCursor(-1) + -- end) + -- set({ 'n', 'x' }, '<leader>S', function() + -- mc.matchSkipCursor(-1) + -- end) + + -- Disable and enable cursors. + -- set({ 'n', 'x' }, '<c-q>', 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' }, '<left>', mc.prevCursor) + layerSet({ 'n', 'x' }, '<right>', mc.nextCursor) + + -- Delete the main cursor. + layerSet({ 'n', 'x' }, '<leader>x', mc.deleteCursor) + + -- Enable and clear cursors using escape. + layerSet('n', '<esc>', 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, +} |
