summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dot-config/nvim/lazy-lock.json1
-rw-r--r--dot-config/nvim/lua/plugins/hardtime.lua11
-rw-r--r--dot-config/nvim/lua/plugins/multicursor.lua85
3 files changed, 96 insertions, 1 deletions
diff --git a/dot-config/nvim/lazy-lock.json b/dot-config/nvim/lazy-lock.json
index f635686..4cc90e0 100644
--- a/dot-config/nvim/lazy-lock.json
+++ b/dot-config/nvim/lazy-lock.json
@@ -19,6 +19,7 @@
"mini.icons": { "branch": "main", "commit": "94848dad1589a199f876539bd79befb0c5e3abf0" },
"mini.pairs": { "branch": "main", "commit": "42407ccb80ec59c84e7c91d815f42ed90a8cc093" },
"mini.surround": { "branch": "main", "commit": "1a2b59c77a0c4713a5bd8972da322f842f4821b1" },
+ "multicursor.nvim": { "branch": "main", "commit": "6fba38bccf45cfb681f4ff6098f886213f299a34" },
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" },
diff --git a/dot-config/nvim/lua/plugins/hardtime.lua b/dot-config/nvim/lua/plugins/hardtime.lua
index 7e6837b..8e8078a 100644
--- a/dot-config/nvim/lua/plugins/hardtime.lua
+++ b/dot-config/nvim/lua/plugins/hardtime.lua
@@ -3,5 +3,14 @@ return {
"m4xshen/hardtime.nvim",
lazy = false,
dependencies = { "MunifTanjim/nui.nvim" },
- opts = {},
+ opts = {
+ -- re-enable <up> <down> <left> <right>
+ -- for use with mutlicursor.nvim
+ disabled_keys = {
+ ["<Up>"] = false,
+ ["<Down>"] = false,
+ ["<Left>"] = false,
+ ["<Right>"] = false,
+ },
+ },
}
diff --git a/dot-config/nvim/lua/plugins/multicursor.lua b/dot-config/nvim/lua/plugins/multicursor.lua
new file mode 100644
index 0000000..6e81074
--- /dev/null
+++ b/dot-config/nvim/lua/plugins/multicursor.lua
@@ -0,0 +1,85 @@
+-- this is the example config shown at https://github.com/jake-stewart/multicursor.nvim/blob/main/readme.md
+-- with the additional changes necessary to work with LazyVIm
+
+return {
+ "jake-stewart/multicursor.nvim",
+ branch = "1.0",
+
+ -- the following changes are necessary to work with LazyVim
+ -- see https://github.com/jake-stewart/multicursor.nvim/issues/107
+ keys = { "<up>", "<down>" }, -- explicitly tell LazyVim used keys to avoid replace
+ lazy = false, -- avoid lazy trying to lazy load based on those keys
+
+ 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)
+
+ -- 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)
+
+ -- Add and remove cursors with control + left click.
+ set("n", "<c-leftmouse>", mc.handleMouse)
+ set("n", "<c-leftdrag>", mc.handleMouseDrag)
+ set("n", "<c-leftrelease>", mc.handleMouseRelease)
+
+ -- 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,
+}