mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 13:53:51 -05:00
Make universal maps global
This commit is contained in:
@@ -5847,10 +5847,6 @@ function! fugitive#Init() abort
|
|||||||
let &mls = save_mls
|
let &mls = save_mls
|
||||||
endtry
|
endtry
|
||||||
endif
|
endif
|
||||||
if !exists('g:fugitive_no_maps')
|
|
||||||
call s:Map('c', '<C-R><C-G>', '<SID>fnameescape(fugitive#Object(@%))', '<expr>')
|
|
||||||
call s:Map('n', 'y<C-G>', ':<C-U>call setreg(v:register, fugitive#Object(@%))<CR>', '<silent>')
|
|
||||||
endif
|
|
||||||
let dir = s:Dir()
|
let dir = s:Dir()
|
||||||
if stridx(&tags, escape(dir, ', ')) == -1 && &tags !~# '\.git' && !exists('s:tags_warning')
|
if stridx(&tags, escape(dir, ', ')) == -1 && &tags !~# '\.git' && !exists('s:tags_warning')
|
||||||
let actualdir = fugitive#Find('.git/', dir)
|
let actualdir = fugitive#Find('.git/', dir)
|
||||||
|
|||||||
@@ -400,3 +400,38 @@ exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject G
|
|||||||
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
||||||
|
|
||||||
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
||||||
|
|
||||||
|
if get(g:, 'fugitive_no_maps')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:nowait = v:version >= 704 ? '<nowait>' : ''
|
||||||
|
|
||||||
|
function! s:Map(mode, lhs, rhs, ...) abort
|
||||||
|
for mode in split(a:mode, '\zs')
|
||||||
|
let flags = (a:0 ? a:1 : '') . (a:rhs =~# '<Plug>' ? '' : '<script>')
|
||||||
|
let head = a:lhs
|
||||||
|
let tail = ''
|
||||||
|
let keys = get(g:, mode.'remap', {})
|
||||||
|
if type(keys) == type([])
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
while !empty(head)
|
||||||
|
if has_key(keys, head)
|
||||||
|
let head = keys[head]
|
||||||
|
if empty(head)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let tail = matchstr(head, '<[^<>]*>$\|.$') . tail
|
||||||
|
let head = substitute(head, '<[^<>]*>$\|.$', '', '')
|
||||||
|
endwhile
|
||||||
|
if flags !~# '<unique>' || empty(mapcheck(head.tail, mode))
|
||||||
|
exe mode.'map' s:nowait flags head.tail a:rhs
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call s:Map('c', '<C-R><C-G>', 'fnameescape(fugitive#Object(@%))', '<expr>')
|
||||||
|
call s:Map('n', 'y<C-G>', ':<C-U>call setreg(v:register, fugitive#Object(@%))<CR>', '<silent>')
|
||||||
|
|||||||
Reference in New Issue
Block a user