From 0927c2e32d62b72a18820dcf4fcf22035861a36f Mon Sep 17 00:00:00 2001 From: a770 Date: Tue, 21 Jan 2025 16:45:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E5=85=89=E6=A0=87=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/lazy/index.lua | 6 ++-- lua/lazy/plugins/indentrainbow.lua | 2 +- lua/lazy/plugins/multicursor.lua | 47 ++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 lua/lazy/plugins/multicursor.lua diff --git a/lua/lazy/index.lua b/lua/lazy/index.lua index 1bf9b0b..97f55c8 100644 --- a/lua/lazy/index.lua +++ b/lua/lazy/index.lua @@ -83,12 +83,14 @@ require("lazy").setup({ require("lazy.plugins.suda"), -- jump使用flash.nvim插件实现,f单个字母时按f下一处,建议先esc退出再可视模式此时才可以继续使用f,斜杠粘贴整个单词查找的时候不好用 require("lazy.plugins.jump"), + -- 多光标 + require("lazy.plugins.multicursor"), -- which-key使用多个字母快捷键停留时会提示 - -- require("lazy.plugins.whichkey"), + require("lazy.plugins.whichkey"), -- cw推荐的indent缩进线hlchunk,可以根据线条的款式来分辨缩进 -- require("lazy.plugins.indent"), -- ai编程助手supermaven -- require("lazy.plugins.supermaven"), - -- 自动补全插件 + -- 自动补全插件nvim-cmp -- require("lazy.plugins.autocomplete").config, }) diff --git a/lua/lazy/plugins/indentrainbow.lua b/lua/lazy/plugins/indentrainbow.lua index a10e917..8731f25 100644 --- a/lua/lazy/plugins/indentrainbow.lua +++ b/lua/lazy/plugins/indentrainbow.lua @@ -11,7 +11,7 @@ return { color_transparency = 0.15, -- The 24-bit colors to mix with the background. Specified in hex. -- { 0xffff40, 0x79ff79, 0xff79ff, 0x4fecec, } by default - colors = { 0xff0000, 0x00ff00, 0x0000ff, 0xffff40, 0x79ff79, 0xff79ff, 0x4fecec}, + colors = {"0xff0000","0x00ff00","0x0000ff","0xffff40","0x79ff79","0xff79ff","0x4fecec"}, })) -- local highlight = { diff --git a/lua/lazy/plugins/multicursor.lua b/lua/lazy/plugins/multicursor.lua new file mode 100644 index 0000000..46d565b --- /dev/null +++ b/lua/lazy/plugins/multicursor.lua @@ -0,0 +1,47 @@ +return { + "jake-stewart/multicursor.nvim", + event = "VeryLazy", + branch = "1.0", + config = function() + local mc = require("multicursor-nvim") + mc.setup() + local set = vim.keymap.set + -- 在主光标上方/下方添加或跳过光标。 + set({ "n", "v" }, "", + function() mc.lineAddCursor(-1) end) + set({ "n", "v" }, "", + function() mc.lineAddCursor(1) end) + set({ "n", "v" }, "", + function() mc.lineSkipCursor(-1) end) + set({ "n", "v" }, "", + function() mc.lineSkipCursor(1) end) + -- 主光标在多光标之间移动。 + set({ "n", "v" }, "", mc.nextCursor) + set({ "n", "v" }, "", mc.prevCursor) + -- 通过匹配单词/选择来添加或跳过添加新光标 + set({ "n", "v" }, "", + function() mc.matchAddCursor(1) end) + set({ "n", "v" }, "k", + function() mc.matchSkipCursor(1) end) + set({ "n", "v" }, "", + function() mc.matchAddCursor(-1) end) + set({ "n", "v" }, "K", + function() mc.matchSkipCursor(-1) end) + -- 使用 Control + 左键单击添加和删除光标。 + set("n", "", mc.handleMouse) + -- 使用主光标添加和删除光标的简单方法。 + set({ "n", "v" }, "m", mc.toggleCursor) + -- 通过正则表达式匹配视觉选择中的新光标。 + set("v", "m", mc.matchCursors) + -- 启用/禁用多光标。 + set("n", "", function() + if not mc.cursorsEnabled() then + mc.enableCursors() + elseif mc.hasCursors() then + mc.clearCursors() + else + -- Default handler. + end + end) + end +}