Skip to content

Commit

Permalink
fix: hide smear in replace mode by default
Browse files Browse the repository at this point in the history
  • Loading branch information
sphamba committed Feb 2, 2025
1 parent fbba581 commit 6d56582
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lua/smear_cursor/animation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions lua/smear_cursor/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lua/smear_cursor/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6d56582

Please sign in to comment.