|
|
|
|
@@ -1,6 +1,6 @@
|
|
|
|
|
" fugitive.vim - A Git wrapper so awesome, it should be illegal
|
|
|
|
|
" Maintainer: Tim Pope <http://tpo.pe/>
|
|
|
|
|
" Version: 3.6
|
|
|
|
|
" Version: 3.3
|
|
|
|
|
" GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim
|
|
|
|
|
|
|
|
|
|
if exists('g:loaded_fugitive')
|
|
|
|
|
@@ -16,9 +16,9 @@ let s:bad_git_dir = '/$\|^fugitive:'
|
|
|
|
|
" Fugitive is active in the current buffer. Do not rely on this for direct
|
|
|
|
|
" filesystem access; use FugitiveFind('.git/whatever') instead.
|
|
|
|
|
function! FugitiveGitDir(...) abort
|
|
|
|
|
if v:version < 703
|
|
|
|
|
if v:version < 704
|
|
|
|
|
return ''
|
|
|
|
|
elseif !a:0 || type(a:1) == type(0) && a:1 < 0 || a:1 is# get(v:, 'true', -1)
|
|
|
|
|
elseif !a:0 || type(a:1) == type(0) && a:1 < 0
|
|
|
|
|
if exists('g:fugitive_event')
|
|
|
|
|
return g:fugitive_event
|
|
|
|
|
endif
|
|
|
|
|
@@ -30,7 +30,7 @@ function! FugitiveGitDir(...) abort
|
|
|
|
|
return b:git_dir
|
|
|
|
|
endif
|
|
|
|
|
return dir =~# s:bad_git_dir ? '' : dir
|
|
|
|
|
elseif type(a:1) == type(0) && a:1 isnot# 0
|
|
|
|
|
elseif type(a:1) == type(0)
|
|
|
|
|
if a:1 == bufnr('') && (!exists('b:git_dir') || b:git_dir =~# s:bad_git_dir) && empty(&buftype)
|
|
|
|
|
let b:git_dir = FugitiveExtractGitDir(expand('%:p'))
|
|
|
|
|
endif
|
|
|
|
|
@@ -55,11 +55,7 @@ endfunction
|
|
|
|
|
" exists, call FooReal("foo://bar").
|
|
|
|
|
function! FugitiveReal(...) abort
|
|
|
|
|
let file = a:0 ? a:1 : @%
|
|
|
|
|
if type(file) ==# type({})
|
|
|
|
|
let dir = FugitiveGitDir(file)
|
|
|
|
|
let tree = s:Tree(dir)
|
|
|
|
|
return FugitiveVimPath(empty(tree) ? dir : tree)
|
|
|
|
|
elseif file =~# '^\a\a\+:' || a:0 > 1
|
|
|
|
|
if file =~# '^\a\a\+:' || a:0 > 1
|
|
|
|
|
return call('fugitive#Real', [file] + a:000[1:-1])
|
|
|
|
|
elseif file =~# '^/\|^\a:\|^$'
|
|
|
|
|
return file
|
|
|
|
|
@@ -76,13 +72,25 @@ endfunction
|
|
|
|
|
" An optional second argument provides the Git dir, or the buffer number of a
|
|
|
|
|
" buffer with a Git dir. The default is the current buffer.
|
|
|
|
|
function! FugitiveFind(...) abort
|
|
|
|
|
if a:0 && (type(a:1) ==# type({}) || type(a:1) ==# type(0))
|
|
|
|
|
if a:0 && type(a:1) ==# type({})
|
|
|
|
|
return call('fugitive#Find', a:000[1:-1] + [FugitiveGitDir(a:1)])
|
|
|
|
|
else
|
|
|
|
|
return fugitive#Find(a:0 ? a:1 : bufnr(''), FugitiveGitDir(a:0 > 1 ? a:2 : -1))
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! FugitivePath(...) abort
|
|
|
|
|
if a:0 > 2 && type(a:1) ==# type({})
|
|
|
|
|
return fugitive#Path(a:2, a:3, FugitiveGitDir(a:1))
|
|
|
|
|
elseif a:0 && type(a:1) ==# type({})
|
|
|
|
|
return FugitiveReal(a:0 > 1 ? a:2 : @%)
|
|
|
|
|
elseif a:0 > 1
|
|
|
|
|
return fugitive#Path(a:1, a:2, FugitiveGitDir(a:0 > 2 ? a:3 : -1))
|
|
|
|
|
else
|
|
|
|
|
return FugitiveReal(a:0 ? a:1 : @%)
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" FugitiveParse() takes a fugitive:// URL and returns a 2 element list
|
|
|
|
|
" containing an object name ("commit:file") and the Git dir. It's effectively
|
|
|
|
|
" the inverse of FugitiveFind().
|
|
|
|
|
@@ -99,14 +107,6 @@ function! FugitiveParse(...) abort
|
|
|
|
|
throw v:errmsg
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" FugitiveGitVersion() queries the version of Git in use. Pass up to 3
|
|
|
|
|
" arguments to return a Boolean of whether a certain minimum version is
|
|
|
|
|
" available (FugitiveGitVersion(2,3,4) checks for 2.3.4 or higher) or no
|
|
|
|
|
" arguments to get a raw string.
|
|
|
|
|
function! FugitiveGitVersion(...) abort
|
|
|
|
|
return call('fugitive#GitVersion', a:000)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" FugitiveResult() returns an object encapsulating the result of the most
|
|
|
|
|
" recent :Git command. Will be empty if no result is available. During a
|
|
|
|
|
" User FugitiveChanged event, this is guaranteed to correspond to the :Git
|
|
|
|
|
@@ -125,43 +125,15 @@ function! FugitiveResult(...) abort
|
|
|
|
|
return call('fugitive#Result', a:000)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" FugitiveExecute() runs Git with a list of arguments and returns a dictionary
|
|
|
|
|
" with the following keys:
|
|
|
|
|
" FugitivePrepare() constructs a Git command string which can be executed with
|
|
|
|
|
" functions like system() and commands like :!. Integer arguments will be
|
|
|
|
|
" treated as buffer numbers, and the appropriate relative path inserted in
|
|
|
|
|
" their place.
|
|
|
|
|
"
|
|
|
|
|
" * "exit_status": The integer exit code of the process.
|
|
|
|
|
" * "stdout": The stdout produced by the process, as a list of lines.
|
|
|
|
|
" * "stderr": The stdout produced by the process, as a list of lines.
|
|
|
|
|
"
|
|
|
|
|
" An optional second argument provides the Git dir, or the buffer number of a
|
|
|
|
|
" buffer with a Git dir. The default is the current buffer.
|
|
|
|
|
"
|
|
|
|
|
" An optional final argument is a callback Funcref, for asynchronous
|
|
|
|
|
" execution.
|
|
|
|
|
function! FugitiveExecute(args, ...) abort
|
|
|
|
|
return call('fugitive#Execute', [a:args] + a:000)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" FugitiveShellCommand() turns an array of arugments into a Git command string
|
|
|
|
|
" which can be executed with functions like system() and commands like :!.
|
|
|
|
|
" Integer arguments will be treated as buffer numbers, and the appropriate
|
|
|
|
|
" relative path inserted in their place.
|
|
|
|
|
"
|
|
|
|
|
" An optional second argument provides the Git dir, or the buffer number of a
|
|
|
|
|
" buffer with a Git dir. The default is the current buffer.
|
|
|
|
|
function! FugitiveShellCommand(...) abort
|
|
|
|
|
return call('fugitive#ShellCommand', a:000)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" FugitivePrepare() is a deprecated alias for FugitiveShellCommand(). If you
|
|
|
|
|
" are using this in conjunction with system(), consider using
|
|
|
|
|
" FugitiveExecute() instead.
|
|
|
|
|
" If the first argument is a string that looks like a path or an empty string,
|
|
|
|
|
" it will be used as the Git dir. If it's a buffer number, the Git dir for
|
|
|
|
|
" that buffer will be used. The default is the current buffer.
|
|
|
|
|
function! FugitivePrepare(...) abort
|
|
|
|
|
if !exists('s:did_prepare_warning')
|
|
|
|
|
let s:did_prepare_warning = 1
|
|
|
|
|
echohl WarningMsg
|
|
|
|
|
unsilent echomsg 'FugitivePrepare() has been superseded by FugitiveShellCommand()'
|
|
|
|
|
echohl NONE
|
|
|
|
|
endif
|
|
|
|
|
return call('fugitive#ShellCommand', a:000)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
@@ -210,35 +182,6 @@ function! FugitiveRemoteUrl(...) abort
|
|
|
|
|
return call('fugitive#RemoteUrl', a:000)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" FugitiveRemote() returns a data structure parsed from the remote URL.
|
|
|
|
|
" For example, for remote URL "https://me@example.com:1234/repo.git", the
|
|
|
|
|
" returned dictionary will contain the following:
|
|
|
|
|
"
|
|
|
|
|
" * "scheme": "https"
|
|
|
|
|
" * "authority": "user@example.com:1234"
|
|
|
|
|
" * "path": "/repo.git" (for SSH URLs this may be a relative path)
|
|
|
|
|
" * "host": "example.com:1234"
|
|
|
|
|
" * "hostname": "example.com"
|
|
|
|
|
" * "port": "1234"
|
|
|
|
|
" * "user": "me"
|
|
|
|
|
" * "path": "/repo.git"
|
|
|
|
|
" * "url": "https://me@example.com:1234/repo.git"
|
|
|
|
|
function! FugitiveRemote(...) abort
|
|
|
|
|
return call('fugitive#Remote', a:000)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" FugitiveDidChange() triggers a FugitiveChanged event and reloads the summary
|
|
|
|
|
" buffer for the current or given buffer number's repository. You can also
|
|
|
|
|
" give the result of a FugitiveExecute() and that context will be made
|
|
|
|
|
" available inside the FugitiveChanged() event.
|
|
|
|
|
"
|
|
|
|
|
" Passing the special argument 0 (the number zero) softly expires summary
|
|
|
|
|
" buffers for all repositories. This can be used after a call to system()
|
|
|
|
|
" with unclear implications.
|
|
|
|
|
function! FugitiveDidChange(...) abort
|
|
|
|
|
return call('fugitive#DidChange', a:000)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" FugitiveHead() retrieves the name of the current branch. If the current HEAD
|
|
|
|
|
" is detached, FugitiveHead() will return the empty string, unless the
|
|
|
|
|
" optional argument is given, in which case the hash of the current commit
|
|
|
|
|
@@ -247,7 +190,7 @@ endfunction
|
|
|
|
|
" An optional second argument provides the Git dir, or the buffer number of a
|
|
|
|
|
" buffer with a Git dir. The default is the current buffer.
|
|
|
|
|
function! FugitiveHead(...) abort
|
|
|
|
|
if a:0 && (type(a:1) ==# type({}) || type(a:1) ==# type('') && a:1 !~# '^\d\+$')
|
|
|
|
|
if a:0 && type(a:1) ==# type({})
|
|
|
|
|
let dir = FugitiveGitDir(a:1)
|
|
|
|
|
let arg = get(a:, 2, 0)
|
|
|
|
|
elseif a:0 > 1
|
|
|
|
|
@@ -263,20 +206,8 @@ function! FugitiveHead(...) abort
|
|
|
|
|
return fugitive#Head(arg, dir)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! FugitivePath(...) abort
|
|
|
|
|
if a:0 > 2 && type(a:1) ==# type({})
|
|
|
|
|
return fugitive#Path(a:2, a:3, FugitiveGitDir(a:1))
|
|
|
|
|
elseif a:0 && type(a:1) ==# type({})
|
|
|
|
|
return FugitiveReal(a:0 > 1 ? a:2 : @%)
|
|
|
|
|
elseif a:0 > 1
|
|
|
|
|
return fugitive#Path(a:1, a:2, FugitiveGitDir(a:0 > 2 ? a:3 : -1))
|
|
|
|
|
else
|
|
|
|
|
return FugitiveReal(a:0 ? a:1 : @%)
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! FugitiveStatusline(...) abort
|
|
|
|
|
if empty(FugitiveGitDir(bufnr('')))
|
|
|
|
|
if empty(get(b:, 'git_dir', ''))
|
|
|
|
|
return ''
|
|
|
|
|
endif
|
|
|
|
|
return fugitive#Statusline()
|
|
|
|
|
@@ -368,13 +299,7 @@ function! s:CeilingDirectories() abort
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! FugitiveExtractGitDir(path) abort
|
|
|
|
|
if type(a:path) ==# type({})
|
|
|
|
|
return get(a:path, 'git_dir', '')
|
|
|
|
|
elseif type(a:path) == type(0)
|
|
|
|
|
let path = s:Slash(a:path >= 0 ? bufname(a:path) : bufname(''))
|
|
|
|
|
else
|
|
|
|
|
let path = s:Slash(a:path)
|
|
|
|
|
endif
|
|
|
|
|
if path =~# '^fugitive:'
|
|
|
|
|
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
|
|
|
|
|
elseif empty(path)
|
|
|
|
|
@@ -430,18 +355,15 @@ function! FugitiveExtractGitDir(path) abort
|
|
|
|
|
return ''
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! FugitiveDetect(...) abort
|
|
|
|
|
if v:version < 703
|
|
|
|
|
function! FugitiveDetect(path) abort
|
|
|
|
|
if v:version < 704
|
|
|
|
|
return ''
|
|
|
|
|
endif
|
|
|
|
|
if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir
|
|
|
|
|
unlet b:git_dir
|
|
|
|
|
endif
|
|
|
|
|
if a:0 > 1 && a:2 is# 0 && !exists('#User#Fugitive')
|
|
|
|
|
return ''
|
|
|
|
|
endif
|
|
|
|
|
if !exists('b:git_dir')
|
|
|
|
|
let b:git_dir = FugitiveExtractGitDir(a:0 ? a:1 : bufnr(''))
|
|
|
|
|
let b:git_dir = FugitiveExtractGitDir(a:path)
|
|
|
|
|
endif
|
|
|
|
|
if empty(b:git_dir) || !exists('#User#Fugitive')
|
|
|
|
|
return ''
|
|
|
|
|
@@ -495,14 +417,14 @@ function! s:ProjectionistDetect() abort
|
|
|
|
|
if exists('+shellslash') && !&shellslash
|
|
|
|
|
let base = tr(base, '/', '\')
|
|
|
|
|
endif
|
|
|
|
|
let file = FugitiveFind('.git/info/projections.json', dir)
|
|
|
|
|
let file = FugitiveCommonDir(dir) . '/info/projections.json'
|
|
|
|
|
if filereadable(file)
|
|
|
|
|
call projectionist#append(base, file)
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
let s:addr_other = has('patch-8.1.560') || has('nvim-0.5.0') ? '-addr=other' : ''
|
|
|
|
|
let s:addr_other = has('patch-8.1.560') ? '-addr=other' : ''
|
|
|
|
|
let s:addr_tabs = has('patch-7.4.542') ? '-addr=tabs' : ''
|
|
|
|
|
let s:addr_wins = has('patch-7.4.542') ? '-addr=windows' : ''
|
|
|
|
|
|
|
|
|
|
@@ -511,22 +433,16 @@ if exists(':G') != 2
|
|
|
|
|
endif
|
|
|
|
|
command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#Complete Git exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)
|
|
|
|
|
|
|
|
|
|
if exists(':Gstatus') != 2 && get(g:, 'fugitive_legacy_commands', 0)
|
|
|
|
|
if exists(':Gstatus') != 2 && get(g:, 'fugitive_legacy_commands', 1)
|
|
|
|
|
exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
\ '|echohl WarningMSG|echomsg ":Gstatus is deprecated in favor of :Git (with no arguments)"|echohl NONE'
|
|
|
|
|
elseif exists(':Gstatus') != 2 && !exists('g:fugitive_legacy_commands')
|
|
|
|
|
exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus'
|
|
|
|
|
\ ' echoerr ":Gstatus has been removed in favor of :Git (with no arguments)"'
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
for s:cmd in ['Commit', 'Revert', 'Merge', 'Rebase', 'Pull', 'Push', 'Fetch', 'Blame']
|
|
|
|
|
if exists(':G' . tolower(s:cmd)) != 2 && get(g:, 'fugitive_legacy_commands', 0)
|
|
|
|
|
if exists(':G' . tolower(s:cmd)) != 2 && get(g:, 'fugitive_legacy_commands', 1)
|
|
|
|
|
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd)
|
|
|
|
|
\ 'echohl WarningMSG|echomsg ":G' . tolower(s:cmd) . ' is deprecated in favor of :Git ' . tolower(s:cmd) . '"|echohl NONE|'
|
|
|
|
|
\ 'exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "' . tolower(s:cmd) . ' " . <q-args>)'
|
|
|
|
|
elseif exists(':G' . tolower(s:cmd)) != 2 && !exists('g:fugitive_legacy_commands')
|
|
|
|
|
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd)
|
|
|
|
|
\ 'echoerr ":G' . tolower(s:cmd) . ' has been removed in favor of :Git ' . tolower(s:cmd) . '"'
|
|
|
|
|
endif
|
|
|
|
|
endfor
|
|
|
|
|
unlet s:cmd
|
|
|
|
|
@@ -535,68 +451,66 @@ exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Gcd
|
|
|
|
|
exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd exe fugitive#Cd(<q-args>, 1)"
|
|
|
|
|
|
|
|
|
|
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#GrepCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Gcgrep exe fugitive#GrepCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#GrepCommand(0, <count> > 0 ? <count> : 0, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
|
|
|
|
|
if exists(':Glog') != 2 && get(g:, 'fugitive_legacy_commands', 0)
|
|
|
|
|
if exists(':Glog') != 2 && get(g:, 'fugitive_legacy_commands', 1)
|
|
|
|
|
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "")'
|
|
|
|
|
\ '|echohl WarningMSG|echomsg ":Glog is deprecated in favor of :Gclog"|echohl NONE'
|
|
|
|
|
elseif exists(':Glog') != 2 && !exists('g:fugitive_legacy_commands')
|
|
|
|
|
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog'
|
|
|
|
|
\ ' echoerr ":Glog has been removed in favor of :Gclog"'
|
|
|
|
|
endif
|
|
|
|
|
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gclog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
|
|
|
|
|
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GcLog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
|
|
|
|
|
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gllog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "l")'
|
|
|
|
|
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GlLog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "l")'
|
|
|
|
|
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ge exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gedit exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#ReadComplete Gpedit exe fugitive#Open("pedit", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "split" : "edit"), <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gvsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "vsplit" : "edit!"), <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#ReadComplete Gtabedit exe fugitive#Open((<count> >= 0 ? <count> : "")."tabedit", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ge exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete 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=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "split" : "edit"), <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gvsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "vsplit" : "edit!"), <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#ReadComplete Gtabedit exe fugitive#Open((<count> >= 0 ? <count> : "")."tabedit", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
|
|
|
|
|
if exists(':Gr') != 2
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
endif
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gread exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gread exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdiffsplit exe fugitive#Diffsplit(1, <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ghdiffsplit exe fugitive#Diffsplit(0, <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gvdiffsplit exe fugitive#Diffsplit(0, <bang>0, "vertical <mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdiffsplit exe fugitive#Diffsplit(1, <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ghdiffsplit exe fugitive#Diffsplit(0, <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gvdiffsplit exe fugitive#Diffsplit(0, <bang>0, "vertical <mods>", <q-args>, [<f-args>])'
|
|
|
|
|
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gw exe fugitive#WriteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwrite exe fugitive#WriteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwq exe fugitive#WqCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gw exe fugitive#WriteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwrite exe fugitive#WriteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gwq exe fugitive#WqCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
|
|
|
|
|
exe 'command! -bar -bang -nargs=0 GRemove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=0 GDelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject GMove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete GRename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=0 GRemove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
exe 'command! -bar -bang -nargs=0 GDelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject GMove exe fugitive#MoveCommand( <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>])'
|
|
|
|
|
if exists(':Gremove') != 2 && get(g:, 'fugitive_legacy_commands', 1)
|
|
|
|
|
exe 'command! -bar -bang -nargs=0 Gremove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=0 Gremove exe fugitive#RemoveCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
\ '|echohl WarningMSG|echomsg ":Gremove is deprecated in favor of :GRemove"|echohl NONE'
|
|
|
|
|
endif
|
|
|
|
|
if exists(':Gdelete') != 2 && get(g:, 'fugitive_legacy_commands', 1)
|
|
|
|
|
exe 'command! -bar -bang -nargs=0 Gdelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=0 Gdelete exe fugitive#DeleteCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
\ '|echohl WarningMSG|echomsg ":Gdelete is deprecated in favor of :GDelete"|echohl NONE'
|
|
|
|
|
endif
|
|
|
|
|
if exists(':Gmove') != 2 && get(g:, 'fugitive_legacy_commands', 1)
|
|
|
|
|
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
|
|
|
|
|
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#CompleteObject Gmove exe fugitive#MoveCommand( <line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>, [<f-args>])'
|
|
|
|
|
\ '|echohl WarningMSG|echomsg ":Gmove is deprecated in favor of :GMove"|echohl NONE'
|
|
|
|
|
endif
|
|
|
|
|
if exists(':Grename') != 2 && get(g:, 'fugitive_legacy_commands', 1)
|
|
|
|
|
exe 'command! -bar -bang -nargs=1 -complete=customlist,fugitive#RenameComplete Grename exe fugitive#RenameCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-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>])'
|
|
|
|
|
\ '|echohl WarningMSG|echomsg ":Grename is deprecated in favor of :GRename"|echohl NONE'
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject GBrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-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 exists(':Gbrowse') != 2 && get(g:, 'fugitive_legacy_commands', 1)
|
|
|
|
|
exe 'command! -bar -bang -range=-1 -nargs=* -complete=customlist,fugitive#CompleteObject Gbrowse exe fugitive#BrowseCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-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 <bang>1|redraw!|endif|echohl WarningMSG|echomsg ":Gbrowse is deprecated in favor of :GBrowse"|echohl NONE'
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if v:version < 703
|
|
|
|
|
if v:version < 704
|
|
|
|
|
finish
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
@@ -620,9 +534,8 @@ let g:io_fugitive = {
|
|
|
|
|
augroup fugitive
|
|
|
|
|
autocmd!
|
|
|
|
|
|
|
|
|
|
autocmd BufNewFile,BufReadPost *
|
|
|
|
|
\ call FugitiveDetect(expand('<amatch>:p'), 0)
|
|
|
|
|
autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand('<afile>:p')), ':p'), 1)
|
|
|
|
|
autocmd BufNewFile,BufReadPost * call FugitiveDetect(expand('<amatch>:p'))
|
|
|
|
|
autocmd FileType netrw call FugitiveDetect(fnamemodify(get(b:, 'netrw_curdir', expand('<amatch>')), ':p'))
|
|
|
|
|
|
|
|
|
|
autocmd FileType git
|
|
|
|
|
\ call fugitive#MapCfile()
|
|
|
|
|
@@ -633,7 +546,7 @@ augroup fugitive
|
|
|
|
|
\ setlocal foldtext=fugitive#Foldtext() |
|
|
|
|
|
\ endif
|
|
|
|
|
autocmd FileType fugitive
|
|
|
|
|
\ call fugitive#MapCfile('fugitive#PorcelainCfile()')
|
|
|
|
|
\ call fugitive#MapCfile('fugitive#StatusCfile()')
|
|
|
|
|
autocmd FileType gitrebase
|
|
|
|
|
\ let &l:include = '^\%(pick\|squash\|edit\|reword\|fixup\|drop\|[pserfd]\)\>' |
|
|
|
|
|
\ if &l:includeexpr !~# 'Fugitive' |
|
|
|
|
|
@@ -645,7 +558,7 @@ augroup fugitive
|
|
|
|
|
autocmd BufReadCmd index{,.lock}
|
|
|
|
|
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
|
|
|
|
|
\ let b:git_dir = s:Slash(expand('<amatch>:p:h')) |
|
|
|
|
|
\ exe fugitive#BufReadStatus(v:cmdbang) |
|
|
|
|
|
\ exe fugitive#BufReadStatus() |
|
|
|
|
|
\ elseif filereadable(expand('<amatch>')) |
|
|
|
|
|
\ silent doautocmd BufReadPre |
|
|
|
|
|
\ keepalt read <amatch> |
|
|
|
|
|
@@ -677,12 +590,15 @@ endif
|
|
|
|
|
|
|
|
|
|
let s:nowait = v:version >= 704 ? '<nowait>' : ''
|
|
|
|
|
|
|
|
|
|
function! s:Map(mode, lhs, rhs, flags) abort
|
|
|
|
|
let flags = a:flags . (a:rhs =~# '<Plug>' ? '' : '<script>')
|
|
|
|
|
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:, a:mode.'remap', {})
|
|
|
|
|
if len(keys) && type(keys) == type({})
|
|
|
|
|
let keys = get(g:, mode.'remap', {})
|
|
|
|
|
if type(keys) == type([])
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
while !empty(head)
|
|
|
|
|
if has_key(keys, head)
|
|
|
|
|
let head = keys[head]
|
|
|
|
|
@@ -694,10 +610,10 @@ function! s:Map(mode, lhs, rhs, flags) abort
|
|
|
|
|
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
|
|
|
|
|
if flags !~# '<unique>' || empty(mapcheck(head.tail, a:mode))
|
|
|
|
|
exe a:mode.'map' s:nowait flags head.tail a:rhs
|
|
|
|
|
endif
|
|
|
|
|
endfor
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
call s:Map('c', '<C-R><C-G>', 'fnameescape(fugitive#Object(@%))', '<expr>')
|
|
|
|
|
|