christoomey / vim-tmux-navigator

Seamless navigation between tmux panes and vim splits
MIT License
5.07k stars 319 forks source link

Run Neovim default <C-l> before TmuxNavigateRight #309

Closed craigmac closed 2 years ago

craigmac commented 2 years ago

This PR detects when we are running Neovim, and if we are runs the default Neovim mapping first, then calls the :TmuxNavigateRight.

The purpose is to respect the default Neovim behaviour. Some may not like this as it is now doing two things: turning off the search highlighting and updating the diff, and then trying to move to the window to the right. Thoughts?

christoomey commented 2 years ago

Hi @craigmac, definitely appreciate the thinking here, but I'm very careful to only include things that are really needed here (trying to keep things as minimal and maintainable as possible).

In this case, the functionality you're describing may make sense for you (definitely surprised to hear it's neovim's default), but since it's possible to replicate this using g:tmux_navigator_no_mappings and defining the mappings directly, I don't think it makes sense to bring this into the core plugin code.

Based on that thinking I'm going to close this without merging, but please feel free to comment or reopen if you think I'm missing something here.

craigmac commented 2 years ago

Sure, makes sense to me and it's what I did. In my vimrc I use this to backport the default from Neovim (Neovim users can adjust for their init.vim to get it working with this plugin):

In ~/.vim/vimrc:

let g:tmux_navigator_no_mappings=1
nnoremap <silent> <C-l> <Cmd>nohlsearch<Bar>diffupdate<Bar>TmuxNavigateRight<CR>
nnoremap <silent> <C-h> <Cmd>TmuxNavigateLeft<cr>
nnoremap <silent> <C-j> <Cmd>TmuxNavigateDown<cr>
nnoremap <silent> <C-k> <Cmd>TmuxNavigateUp<cr>
nnoremap <silent> <C-\> <Cmd>TmuxNavigatePrevious<cr>
craigmac commented 2 years ago

definitely surprised to hear it's neovim's default

To be fair, Neovim does call plain ol' <C-l> at the end of their remapping in Neovim, it's just that it won't work with this plugin that way because of script loading order.