Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support specifying resize step in resize_* methods #127

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions lua/tmux/resize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,47 +35,51 @@ function M.setup()
end
end

function M.to_left()
function M.to_left(step)
step = step or options.resize.resize_step_x
local is_border = nvim.is_nvim_border("l")
if is_border and is_tmux_target("l") then
tmux.resize("h", options.resize.resize_step_x)
tmux.resize("h", step)
elseif is_border then
nvim.resize("x", "+", options.resize.resize_step_x)
nvim.resize("x", "+", step)
else
vim.fn.win_move_separator(0, -options.resize.resize_step_x)
vim.fn.win_move_separator(0, -step)
end
end

function M.to_bottom()
function M.to_bottom(step)
step = step or options.resize.resize_step_y
local is_border = nvim.is_nvim_border("j")
if is_border and is_tmux_target("j") then
tmux.resize("j", options.resize.resize_step_y)
tmux.resize("j", step)
elseif is_border then
nvim.resize("y", "-", options.resize.resize_step_y)
nvim.resize("y", "-", step)
else
vim.fn.win_move_statusline(0, options.resize.resize_step_y)
vim.fn.win_move_statusline(0, step)
end
end

function M.to_top()
function M.to_top(step)
step = step or options.resize.resize_step_y
local is_border = nvim.is_nvim_border("j")
if is_border and is_tmux_target("j") then
tmux.resize("k", options.resize.resize_step_y)
tmux.resize("k", step)
elseif is_border then
nvim.resize("y", "+", options.resize.resize_step_y)
nvim.resize("y", "+", step)
else
vim.fn.win_move_statusline(0, -options.resize.resize_step_y)
vim.fn.win_move_statusline(0, -step)
end
end

function M.to_right()
function M.to_right(step)
step = step or options.resize.resize_step_x
local is_border = nvim.is_nvim_border("l")
if is_border and is_tmux_target("l") then
tmux.resize("l", options.resize.resize_step_x)
tmux.resize("l", step)
elseif is_border then
nvim.resize("x", "-", options.resize.resize_step_x)
nvim.resize("x", "-", step)
else
vim.fn.win_move_separator(0, options.resize.resize_step_x)
vim.fn.win_move_separator(0, step)
end
end

Expand Down
Loading