From 6d56582f73daffc4d6569545cc2283bb6590398e Mon Sep 17 00:00:00 2001 From: Son Pham-Ba Date: Sun, 2 Feb 2025 23:19:12 +0100 Subject: [PATCH] fix: hide smear in replace mode by default --- lua/smear_cursor/animation.lua | 11 ++++++++++- lua/smear_cursor/config.lua | 6 ++++++ lua/smear_cursor/events.lua | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lua/smear_cursor/animation.lua b/lua/smear_cursor/animation.lua index 3d2d247..51a6226 100644 --- a/lua/smear_cursor/animation.lua +++ b/lua/smear_cursor/animation.lua @@ -31,12 +31,21 @@ local function cursor_is_vertical_bar() end end +local function cursor_is_horizontal_bar() + return vim.api.nvim_get_mode().mode == "R" and config.horizontal_bar_cursor_replace_mode +end + local function set_corners(corners, row, col) - corners[1] = { row, col } if cursor_is_vertical_bar() then + corners[1] = { row, col } corners[2] = { row, col + 1 / 8 } corners[3] = { row + 1, col + 1 / 8 } + elseif cursor_is_horizontal_bar() then + corners[1] = { row + 7 / 8, col } + corners[2] = { row + 7 / 8, col + 1 } + corners[3] = { row + 1, col + 1 } else + corners[1] = { row, col } corners[2] = { row, col + 1 } corners[3] = { row + 1, col + 1 } end diff --git a/lua/smear_cursor/config.lua b/lua/smear_cursor/config.lua index 1e7f343..813d583 100644 --- a/lua/smear_cursor/config.lua +++ b/lua/smear_cursor/config.lua @@ -36,6 +36,12 @@ M.smear_insert_mode = true -- Set to `true` if your cursor is a vertical bar in insert mode. M.vertical_bar_cursor_insert_mode = true +-- Smear cursor in replace mode. +M.smear_replace_mode = false + +-- Set to `true` if your cursor is a horizontal bar in replace mode. +M.horizontal_bar_cursor_replace_mode = true + -- Attempt to hide the real cursor by drawing a character below it. -- Can be useful when not using `termguicolors` M.hide_target_hack = false diff --git a/lua/smear_cursor/events.lua b/lua/smear_cursor/events.lua index a7555ba..18df38c 100644 --- a/lua/smear_cursor/events.lua +++ b/lua/smear_cursor/events.lua @@ -19,6 +19,8 @@ local function move_cursor(trigger, jump) local row, col local mode = vim.api.nvim_get_mode().mode + if mode == "R" and not config.smear_replace_mode then jump = true end + if mode ~= "c" then row, col = screen.get_screen_cursor_position() elseif config.smear_to_cmd then