Multicursors !

This commit is contained in:
2026-10-02 17:36:40 +02:00
parent 50ba3ef8a1
commit 8fe8988de0
5 changed files with 19 additions and 103 deletions
+1
View File
@@ -16,3 +16,4 @@ vim.keymap.set({ "n", "x", "o" }, "S", function() Flash.treesitter() end)
vim.keymap.set({ "o" }, "r", function() Flash.remote() end)
vim.keymap.set({ "o", "x" }, "R", function() Flash.treesitter_search() end)
vim.keymap.set({ "c" }, "<c-s>", function() Flash.toggle() end)
-- vim.keymap.set({"n"}, "")
-1
View File
@@ -4,7 +4,6 @@ require("plugins.treesitter")
require("plugins.lsp")
require("plugins.oil")
require("plugins.cmp")
require("plugins.multicursor")
require("plugins.lsplines")
require("plugins.mini")
require("plugins.flash")
-87
View File
@@ -1,87 +0,0 @@
vim.pack.add({ "https://github.com/jake-stewart/multicursor.nvim" })
local mc = require("multicursor-nvim")
mc.setup()
local set = vim.keymap.set
-- Add or skip cursor above/below the main cursor.
set({ "n", "x" }, "<C-M-k>", function()
mc.lineAddCursor(-1)
end)
set({ "n", "x" }, "<C-M-j>", function()
mc.lineAddCursor(1)
end)
set({ "n", "x" }, "<C-M-S-k>", function()
mc.lineSkipCursor(-1)
end)
set({ "n", "x" }, "<C-M-S-j>", function()
mc.lineSkipCursor(1)
end)
-- Add or skip adding a new cursor by matching word/selection
set({ "n", "x" }, "<C-j>", function()
mc.matchAddCursor(1)
end)
set({ "n", "x" }, "<C-S-j>", function()
mc.matchSkipCursor(1)
end)
set({ "n", "x" }, "<C-k>", function()
mc.matchAddCursor(-1)
end)
set({ "n", "x" }, "<C-S-k>", 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, fg = "#aaaaff" })
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" })
-- Autocmds to change main cursor color when multicursors is active
vim.api.nvim_create_autocmd("User", {
pattern = "MultiCursorStart",
callback = function()
vim.api.nvim_set_hl(0, "Cursor", { bg = "#000000", fg = "#ffffff" }) -- bright red
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MultiCursorExit",
callback = function()
vim.api.nvim_set_hl(0, "Cursor", { link = "Cursor" }) -- restore default
end,
})
+4 -1
View File
@@ -73,7 +73,10 @@ ts.install(languages):wait(300000)
for _, lang in pairs(languages) do
vim.api.nvim_create_autocmd('FileType', {
pattern = { lang },
callback = function() vim.treesitter.start() end,
callback = function()
vim.treesitter.start()
--vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end,
})
end
+14 -14
View File
@@ -5,31 +5,31 @@
"src": "https://github.com/numToStr/Comment.nvim"
},
"blink.cmp": {
"rev": "91774548bc358c02fcc327d33c9ac0d9830c8c47",
"rev": "8219b58f1c11a2fb1644d3c7116c509fa8348ec0",
"src": "https://github.com/saghen/blink.cmp"
},
"blink.lib": {
"rev": "b127d48bf8e9ac9cf41f6e0fbead317503f76558",
"rev": "fd9a48ebbe6ec30d5dfcc5b42c243941ccdca1aa",
"src": "https://github.com/saghen/blink.lib"
},
"colorful-menu.nvim": {
"rev": "13f9b7eaa9cd2901b4f8915cfb2483c3be4c8c20",
"rev": "196ddf16d5f8fec09ba7f20e6b153aa5188e907b",
"src": "https://github.com/xzbdmw/colorful-menu.nvim"
},
"conform.nvim": {
"rev": "619363c30309d29ffa631e67c8183f2a72caa373",
"rev": "016802de402556da54c36bd7359b441266b01cdd",
"src": "https://github.com/stevearc/conform.nvim"
},
"fidget.nvim": {
"rev": "82404b196e73a00b1727a91903beef5ddc319d22",
"rev": "9e0201673e08e997e7cf52afca5565c70bd117f3",
"src": "https://github.com/j-hui/fidget.nvim"
},
"flash.nvim": {
"rev": "fcea7ff883235d9024dc41e638f164a450c14ca2",
"rev": "5f0f270fdc7c5b0c21d903ee85b9cb06f2ac636a",
"src": "https://github.com/folke/flash.nvim"
},
"gitsigns.nvim": {
"rev": "25050e4ed39e628282831d4cbecb1850454ce915",
"rev": "070a5d7b985546cc57e1fc61e5bc507fecac6045",
"src": "https://github.com/lewis6991/gitsigns.nvim"
},
"lsp_lines.nvim": {
@@ -49,15 +49,15 @@
"src": "https://github.com/xero/miasma.nvim"
},
"mini.comment": {
"rev": "fc87ba6554f182161d9a4bab5017c575571f000f",
"rev": "27a29d6b949b9497f80a0a03421e89fed71d8c37",
"src": "https://github.com/nvim-mini/mini.comment"
},
"mini.icons": {
"rev": "ac38c983aed0a2bd32a65ca3e2348e12e58ca292",
"rev": "f642e3ba8c12afbc8f32f6d77ef6597eac56786f",
"src": "https://github.com/nvim-mini/mini.icons"
},
"mini.surround": {
"rev": "d401c3856585473693e5ce9ec4c8e5b608b4c0fe",
"rev": "33a2ebe5df8eb4751828fcba133e18ed0fbbdfab",
"src": "https://github.com/nvim-mini/mini.surround"
},
"multicursor.nvim": {
@@ -73,15 +73,15 @@
"src": "https://github.com/rose-pine/neovim"
},
"nvim-lspconfig": {
"rev": "a683e0ddf0cf64c6cd689e18ffb480ade3c162b7",
"rev": "3e8d598d3b5f8338a41699c436e5fa11d2666cf0",
"src": "https://github.com/neovim/nvim-lspconfig"
},
"nvim-metals": {
"rev": "4cc98f07ec96bb748a8796831767538e0e4f9be4",
"rev": "a4b20656bf1014404dd63bf9fd5f22fcc50fee52",
"src": "https://github.com/scalameta/nvim-metals"
},
"nvim-treesitter": {
"rev": "4916d6592ede8c07973490d9322f187e07dfefac",
"rev": "910fdf6f49e9dee7e7257c7d11a76b040fdfb9de",
"src": "https://github.com/nvim-treesitter/nvim-treesitter",
"version": "'main'"
},
@@ -102,7 +102,7 @@
"src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
},
"telescope.nvim": {
"rev": "9377230aa5305d9e9aca4ed8dadf1070fb4aa9fc",
"rev": "40aedd8a68c78a656a10a8d62d80c54af59420fb",
"src": "https://github.com/nvim-lua/telescope.nvim"
},
"torchlight.nvim": {