Skip to content

Commit

Permalink
Prevent resizing in Vim under certain situations (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanMillerC authored Apr 24, 2020
1 parent b770109 commit 530c632
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plugin/better_vim_tmux_resizer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ if !exists("g:tmux_resizer_no_mappings")
endif

function! s:VimResize(direction)
" Prevent resizing Vim upward when there is only a single window
if (a:direction == 'j' && winnr('$') <= 1)
return
endif

" Prevent resizing Vim upward when down is pressed with all vsplit windows
if (a:direction == 'k')
let l:all_windows_are_vsplit = 1
for l:window in range(1, winnr('$'))
if (win_screenpos(l:window)[0] != 1)
let l:all_windows_are_vsplit = 0
endif
endfor
if (l:all_windows_are_vsplit)
return
endif
endif

" Resize Vim window toward given direction, like tmux
let l:current_window_is_last_window = (winnr() == winnr('$'))
if (a:direction == 'h' || a:direction == 'k')
Expand Down

0 comments on commit 530c632

Please sign in to comment.