christoomey / vim-tmux-navigator

Seamless navigation between tmux panes and vim splits

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Navigate buffers when zoomed in?

schontz opened this issue · comments

Before I discovered this wonderful plugin, I had the following maps:

  nnoremap <C-L> :bn<CR>
  nnoremap <C-H> :bp<CR>

This is handy for me in the workflow of "has nerd tree and one buffer open"

Ideally, I would like to use a combo of these and the plugin:

  1. If tmux is zoomed out, use plugin as is
  2. If tmux is zoomed in, and only one buffer is open, use the above mappings
  3. If tmux is zoomed in, and there are multiple buffers open, use the plugin as is

I know the answer is probably fork it, but thought I would just throw this out there anyway.

Thanks for all the wonderful work.

For anyone who might come across this, I ended up with something like the following:

  " Disable tmux navigator when zooming the Vim pane
  let g:tmux_navigator_disable_when_zoomed = 1

  " Use custom mappings
  let g:tmux_navigator_no_mappings = 1

  function! NavLeft()
    if tabpagewinnr(tabpagenr(), '$') == 1
      execute ":bp"
    else
      execute ":TmuxNavigateLeft"
    endif
  endfunction

  function! NavRight()
    if tabpagewinnr(tabpagenr(), '$') == 1
      execute ":bn"
    else
      execute ":TmuxNavigateRight"
    endif
  endfunction

  nnoremap <silent> <C-h> :call NavLeft()<cr>
  nnoremap <silent> <C-l> :call NavRight()<cr>