Skip to content

Commit 307bad9

Browse files
authored
Support specifying resize step in resize_* methods (#127)
closes #125
1 parent 65ee9d6 commit 307bad9

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

lua/tmux/resize.lua

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,47 +35,51 @@ function M.setup()
3535
end
3636
end
3737

38-
function M.to_left()
38+
function M.to_left(step)
39+
step = step or options.resize.resize_step_x
3940
local is_border = nvim.is_nvim_border("l")
4041
if is_border and is_tmux_target("l") then
41-
tmux.resize("h", options.resize.resize_step_x)
42+
tmux.resize("h", step)
4243
elseif is_border then
43-
nvim.resize("x", "+", options.resize.resize_step_x)
44+
nvim.resize("x", "+", step)
4445
else
45-
vim.fn.win_move_separator(0, -options.resize.resize_step_x)
46+
vim.fn.win_move_separator(0, -step)
4647
end
4748
end
4849

49-
function M.to_bottom()
50+
function M.to_bottom(step)
51+
step = step or options.resize.resize_step_y
5052
local is_border = nvim.is_nvim_border("j")
5153
if is_border and is_tmux_target("j") then
52-
tmux.resize("j", options.resize.resize_step_y)
54+
tmux.resize("j", step)
5355
elseif is_border then
54-
nvim.resize("y", "-", options.resize.resize_step_y)
56+
nvim.resize("y", "-", step)
5557
else
56-
vim.fn.win_move_statusline(0, options.resize.resize_step_y)
58+
vim.fn.win_move_statusline(0, step)
5759
end
5860
end
5961

60-
function M.to_top()
62+
function M.to_top(step)
63+
step = step or options.resize.resize_step_y
6164
local is_border = nvim.is_nvim_border("j")
6265
if is_border and is_tmux_target("j") then
63-
tmux.resize("k", options.resize.resize_step_y)
66+
tmux.resize("k", step)
6467
elseif is_border then
65-
nvim.resize("y", "+", options.resize.resize_step_y)
68+
nvim.resize("y", "+", step)
6669
else
67-
vim.fn.win_move_statusline(0, -options.resize.resize_step_y)
70+
vim.fn.win_move_statusline(0, -step)
6871
end
6972
end
7073

71-
function M.to_right()
74+
function M.to_right(step)
75+
step = step or options.resize.resize_step_x
7276
local is_border = nvim.is_nvim_border("l")
7377
if is_border and is_tmux_target("l") then
74-
tmux.resize("l", options.resize.resize_step_x)
78+
tmux.resize("l", step)
7579
elseif is_border then
76-
nvim.resize("x", "-", options.resize.resize_step_x)
80+
nvim.resize("x", "-", step)
7781
else
78-
vim.fn.win_move_separator(0, options.resize.resize_step_x)
82+
vim.fn.win_move_separator(0, step)
7983
end
8084
end
8185

0 commit comments

Comments
 (0)