tmux-plugins/vim-tmux

Test for buffer-local mapping

y opened this issue · 3 comments

y commented

Some plugins set global mapping, but vim uses buffer mappings before global ones. Since this plugin is setting a buffer mapping, test for an existing buffer mapping, not a global mapping.

diff --git a/ftplugin/tmux.vim b/ftplugin/tmux.vim
index a2f4c88..49d909e 100644
--- a/ftplugin/tmux.vim
+++ b/ftplugin/tmux.vim
@@ -9,8 +9,15 @@ set cpo&vim
setlocal comments=:#
setlocal commentstring=#\ %s

-if maparg('K','n') ==# ''
-  nnoremap <silent><buffer> K :call tmux#man()<CR>
+if v:version + has('patch32') >= 704
+    let s:map_dict = maparg('K', 'n', 0, 1)
+    if empty(s:map_dict) || ! s:map_dict['buffer']
+        nnoremap <silent><buffer> K :call tmux#man()<CR>
+    endif
+else
+    if maparg('K','n') ==# ''
+        nnoremap <silent><buffer> K :call tmux#man()<CR>
+    endif
endif

nnoremap <silent> <Plug>TmuxExec :<C-U>set opfunc=tmux#filterop<CR>g@

Applied, thanks.

Hey, we're having some issues with this patch in issue #1.

I just tested this and it turns out that maparg('K','n') (the old code) also tests for buffer mappings. This means the proposed patch is not necessary.

This patch is now reverted. I expect there will be no problems with the functionality, but let me know if opposite is true.