mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-13 22:03:51 -05:00
Make :Gcd global
This commit is contained in:
@@ -2175,22 +2175,20 @@ endfunction
|
|||||||
|
|
||||||
" Section: :Gcd, :Glcd
|
" 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 =~# "/$"')
|
return filter(fugitive#CompletePath(a:A), 'v:val =~# "/$"')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:DirArg(path) abort
|
function! fugitive#Cd(path, ...) abort
|
||||||
let path = substitute(a:path, '^:/:\=\|^:(\%(top\|top,literal\|literal,top\|literal\))', '', '')
|
let path = substitute(a:path, '^:/:\=\|^:(\%(top\|top,literal\|literal,top\|literal\))', '', '')
|
||||||
if path =~# '^/\|^\a\+:\|^\.\.\=\%(/\|$\)'
|
if path !~# '^/\|^\a\+:\|^\.\.\=\%(/\|$\)'
|
||||||
return path
|
let dir = s:Dir()
|
||||||
else
|
exe s:DirCheck(dir)
|
||||||
return FugitiveVimPath((empty(s:Tree()) ? s:Dir() : s:Tree()) . '/' . path)
|
let path = (empty(s:Tree(dir)) ? dir : s:Tree(dir)) . '/' . path
|
||||||
endif
|
endif
|
||||||
|
return (a:0 && a:1 ? 'lcd ' : 'cd ') . s:fnameescape(FugitiveVimPath(path))
|
||||||
endfunction
|
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
|
" Section: :Gstatus
|
||||||
|
|
||||||
call s:command("-bar -bang -range=-1 -addr=other Gstatus", "Status")
|
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 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! -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 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#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>])'
|
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