Provide g:fugitive_defer_to_existing_maps

References: https://github.com/tpope/vim-fugitive/issues/1425
This commit is contained in:
Tim Pope
2022-03-25 18:07:25 -04:00
parent b6405d8908
commit 8157efff49
2 changed files with 3 additions and 3 deletions

View File

@@ -208,7 +208,7 @@ let s:nowait = v:version >= 704 ? '<nowait>' : ''
function! s:Map(mode, lhs, rhs, ...) abort function! s:Map(mode, lhs, rhs, ...) abort
let maps = [] let maps = []
let unique = a:0 && a:1 =~# '<unique>' let defer = a:0 && a:1 =~# '<unique>' || get(g:, 'fugitive_defer_to_existing_maps')
let flags = substitute(a:0 ? a:1 : '', '<unique>', '', '') . (a:rhs =~# '<Plug>' ? '' : '<script>') . s:nowait let flags = substitute(a:0 ? a:1 : '', '<unique>', '', '') . (a:rhs =~# '<Plug>' ? '' : '<script>') . s:nowait
for mode in split(a:mode, '\zs') for mode in split(a:mode, '\zs')
if a:0 <= 1 if a:0 <= 1
@@ -230,7 +230,7 @@ function! s:Map(mode, lhs, rhs, ...) abort
let tail = matchstr(head, '<[^<>]*>$\|.$') . tail let tail = matchstr(head, '<[^<>]*>$\|.$') . tail
let head = substitute(head, '<[^<>]*>$\|.$', '', '') let head = substitute(head, '<[^<>]*>$\|.$', '', '')
endwhile endwhile
if !skip && (!unique || empty(mapcheck(head.tail, mode))) if !skip && (!defer || empty(mapcheck(head.tail, mode)))
call add(maps, mode.'map <buffer>' . flags . ' ' . head.tail . ' ' . a:rhs) call add(maps, mode.'map <buffer>' . flags . ' ' . head.tail . ' ' . a:rhs)
if a:0 > 1 && a:2 if a:0 > 1 && a:2
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') .

View File

@@ -725,7 +725,7 @@ function! s:Map(mode, lhs, rhs, flags) abort
let head = substitute(head, '<[^<>]*>$\|.$', '', '') let head = substitute(head, '<[^<>]*>$\|.$', '', '')
endwhile endwhile
endif endif
if flags !~# '<unique>' || empty(mapcheck(head.tail, a:mode)) if empty(mapcheck(head.tail, a:mode))
exe a:mode.'map' s:nowait flags head.tail a:rhs exe a:mode.'map' s:nowait flags head.tail a:rhs
endif endif
endfunction endfunction