From 3cbae67bbd1c67c8e97f4c166022810b07eb8a91 Mon Sep 17 00:00:00 2001 From: rootiest Date: Fri, 4 Oct 2024 14:00:41 -0400 Subject: [PATCH] refactor: improve multicursor config --- lua/data/func.lua | 20 +++++++++++++++++--- lua/plugins/util.lua | 13 +++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/lua/data/func.lua b/lua/data/func.lua index 4df730f..cc1dea9 100644 --- a/lua/data/func.lua +++ b/lua/data/func.lua @@ -1202,15 +1202,19 @@ end function M.mc_statusline() local mc = require("multicursor-nvim") local status = {} - if mc.hasCursors() then + if mc.numEnabledCursors() > 1 then status.enabled = true + status.cursors = mc.numEnabledCursors() + status.disabled = mc.numDisabledCursors() if vim.fn.mode() == "v" then - status.icon = "󰚕 " + -- status.icon = "󰚕 " + status.icon = "󰆿" status.short_text = "V" status.text = "VISUAL" status.color = "lualine_a_visual" else - status.icon = "󰬸 " + -- status.icon = "󰬸 " + status.icon = "󰇀" status.short_text = "N" status.text = "NORMAL" status.color = "lualine_a_normal" @@ -1221,9 +1225,19 @@ function M.mc_statusline() status.short_text = "NO" status.text = "SINGLE" status.color = "lualine_a_normal" + status.cursors = 1 + status.disabled = 0 end status.icon_short_text = status.icon .. status.short_text status.icon_text = status.icon .. status.text + + if status.cursors > 1 and status.disabled > 0 then + status.count = status.cursors .. "/" .. status.disabled + elseif status.cursors > 1 and status.disabled <= 0 then + status.count = status.cursors + else + status.count = "" + end return status end diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua index 5e7f1b1..5c3b147 100644 --- a/lua/plugins/util.lua +++ b/lua/plugins/util.lua @@ -194,13 +194,14 @@ return { config = function() local mc = require("multicursor-nvim") - mc.setup() + mc.setup({ + -- set to true if you want multicursor undo history + -- to clear when clearing cursors + shallowUndo = false, - -- Customize how cursors look. - vim.api.nvim_set_hl(0, "MultiCursorCursor", { link = "Cursor" }) - vim.api.nvim_set_hl(0, "MultiCursorVisual", { link = "Visual" }) - vim.api.nvim_set_hl(0, "MultiCursorDisabledCursor", { link = "Visual" }) - vim.api.nvim_set_hl(0, "MultiCursorDisabledVisual", { link = "Visual" }) + -- set to empty table to disable signs + signs = { "⎸", "󰇀", "⎹" }, + }) end, }, }