From 1f07473b5771dc2bfe651a3f85279113aa916dbd Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sun, 11 Aug 2019 18:56:10 +0100 Subject: [PATCH] Use tmux window option for pane change detection Improve tmux integration when changing buffers or panes when vim was invoked by another process so that seamless navigation works when the `vim$TMUX_PANE` window option has been set, not only when the pane's command matches a simple regex. --- plugin/autocmds.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugin/autocmds.vim b/plugin/autocmds.vim index f55c310..9f11c68 100644 --- a/plugin/autocmds.vim +++ b/plugin/autocmds.vim @@ -1,6 +1,13 @@ augroup benieAugroup autocmd! + if $TMUX !=# '' + " Set tmux window option to detect when to change pane. + let s:tmux_option = '@vim'.substitute($TMUX_PANE, '%', '\\%', 'g') + call system('tmux set-window-option '.s:tmux_option.' 1') + au VimLeave * call system('tmux set-window-option -u '.s:tmux_option) + endif + " Reopening a file at last curson position au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") \ | exe "normal! g'\"" | endif