Skip to content

Commit

Permalink
feat: add min smear activation distances (horizontal and vertical)
Browse files Browse the repository at this point in the history
  • Loading branch information
sphamba committed Jan 17, 2025
1 parent 005b50b commit 1eb908b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ return {
smear_between_buffers = true,

-- Smear cursor when moving within line or to neighbor lines.
-- Use `min_horizontal_distance_smear` and `min_vertical_distance_smear` for finer control
smear_between_neighbor_lines = true,

-- Draw the smear in buffer space instead of screen space when scrolling
Expand Down
11 changes: 10 additions & 1 deletion lua/smear_cursor/animation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,16 @@ M.change_target_position = function(row, col)

if current_window_id == previous_window_id and current_buffer_id == previous_buffer_id then
if config.scroll_buffer_space then scroll_buffer_space() end
if not config.smear_between_neighbor_lines and not animating and math.abs(row - target_position[1]) <= 1 then
if
not animating
and (
(not config.smear_between_neighbor_lines and math.abs(row - target_position[1]) <= 1)
or (
math.abs(row - target_position[1]) < config.min_vertical_distance_smear
and math.abs(col - target_position[2]) < config.min_horizontal_distance_smear
)
)
then
M.jump(row, col)
return
end
Expand Down
5 changes: 5 additions & 0 deletions lua/smear_cursor/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ local M = {}
M.smear_between_buffers = true

-- Smear cursor when moving within line or to neighbor lines
-- Use `min_horizontal_distance_smear` and `min_vertical_distance_smear` for finer control
M.smear_between_neighbor_lines = true

-- Only smear cursor when moving at least these distances
M.min_horizontal_distance_smear = 0
M.min_vertical_distance_smear = 0

-- Smear cursor when entering or leaving command line mode
M.smear_to_cmd = true

Expand Down

0 comments on commit 1eb908b

Please sign in to comment.