mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 13:53:51 -05:00
Make :Gcd global
This commit is contained in:
@@ -2175,22 +2175,20 @@ endfunction
|
||||
|
||||
" Section: :Gcd, :Glcd
|
||||
|
||||
function! s:DirComplete(A, L, P) abort
|
||||
function! fugitive#CdComplete(A, L, P) abort
|
||||
return filter(fugitive#CompletePath(a:A), 'v:val =~# "/$"')
|
||||
endfunction
|
||||
|
||||
function! s:DirArg(path) abort
|
||||
function! fugitive#Cd(path, ...) abort
|
||||
let path = substitute(a:path, '^:/:\=\|^:(\%(top\|top,literal\|literal,top\|literal\))', '', '')
|
||||
if path =~# '^/\|^\a\+:\|^\.\.\=\%(/\|$\)'
|
||||
return path
|
||||
else
|
||||
return FugitiveVimPath((empty(s:Tree()) ? s:Dir() : s:Tree()) . '/' . path)
|
||||
if path !~# '^/\|^\a\+:\|^\.\.\=\%(/\|$\)'
|
||||
let dir = s:Dir()
|
||||
exe s:DirCheck(dir)
|
||||
let path = (empty(s:Tree(dir)) ? dir : s:Tree(dir)) . '/' . path
|
||||
endif
|
||||
return (a:0 && a:1 ? 'lcd ' : 'cd ') . s:fnameescape(FugitiveVimPath(path))
|
||||
endfunction
|
||||
|
||||
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Gcd :exe s:DirCheck()|exe 'cd<bang>' s:fnameescape(s:DirArg(<q-args>))")
|
||||
call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Glcd :exe s:DirCheck()|exe 'lcd<bang>' s:fnameescape(s:DirArg(<q-args>))")
|
||||
|
||||
" Section: :Gstatus
|
||||
|
||||
call s:command("-bar -bang -range=-1 -addr=other Gstatus", "Status")
|
||||
|
||||
@@ -362,6 +362,9 @@ let s:addr_tabs = has('patch-7.4.542') ? '-addr=tabs' : ''
|
||||
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#Complete G exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
||||
exe 'command! -bang -nargs=? -range=-1' s:addr_other '-complete=customlist,fugitive#Complete Git exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
||||
|
||||
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Gcd exe fugitive#Cd(<q-args>, 0)"
|
||||
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(<q-args>, 1)"
|
||||
|
||||
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Ge exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>, [<f-args>])'
|
||||
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#CompleteObject Gedit exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>, [<f-args>])'
|
||||
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#ReadComplete Gpedit exe fugitive#Open("pedit", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
||||
|
||||
Reference in New Issue
Block a user