mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -63,6 +63,7 @@ that are part of Git repositories).
|
||||
U |:Git| checkout HEAD (staged files)
|
||||
U |:Git| clean (untracked files)
|
||||
U |:Git| rm (unmerged files)
|
||||
. enter |:| command line with file prepopulated
|
||||
|
||||
*fugitive-:Gcommit*
|
||||
:Gcommit [args] A wrapper around git-commit. If there is nothing
|
||||
@ -89,7 +90,7 @@ that are part of Git repositories).
|
||||
|
||||
*fugitive-:Grebase*
|
||||
:Grebase [args] Like |:Gmerge|, but for git-rebase. Interactive
|
||||
rebase not suppported.
|
||||
rebase not supported.
|
||||
|
||||
*fugitive-:Gpush*
|
||||
:Gpush [args] Invoke git-push, load the results into the |quickfix|
|
||||
@ -124,19 +125,19 @@ that are part of Git repositories).
|
||||
|quickfix| list.
|
||||
|
||||
*fugitive-:Gedit* *fugitive-:Ge*
|
||||
:Gedit [revision] |:edit| a |fugitive-revision|.
|
||||
:Gedit [object] |:edit| a |fugitive-object|.
|
||||
|
||||
*fugitive-:Gsplit*
|
||||
:Gsplit [revision] |:split| a |fugitive-revision|.
|
||||
:Gsplit [object] |:split| a |fugitive-object|.
|
||||
|
||||
*fugitive-:Gvsplit*
|
||||
:Gvsplit [revision] |:vsplit| a |fugitive-revision|.
|
||||
:Gvsplit [object] |:vsplit| a |fugitive-object|.
|
||||
|
||||
*fugitive-:Gtabedit*
|
||||
:Gtabedit [revision] |:tabedit| a |fugitive-revision|.
|
||||
:Gtabedit [object] |:tabedit| a |fugitive-object|.
|
||||
|
||||
*fugitive-:Gpedit*
|
||||
:Gpedit [revision] |:pedit| a |fugitive-revision|.
|
||||
:Gpedit [object] |:pedit| a |fugitive-object|.
|
||||
|
||||
:Gsplit! [args] *fugitive-:Gsplit!* *fugitive-:Gvsplit!*
|
||||
:Gvsplit! [args] *fugitive-:Gtabedit!* *fugitive-:Gpedit!*
|
||||
@ -144,13 +145,12 @@ that are part of Git repositories).
|
||||
:Gpedit! [args] split, tab, or preview window.
|
||||
|
||||
*fugitive-:Gread*
|
||||
:Gread [revision] Empty the buffer and |:read| a |fugitive-revision|.
|
||||
:Gread [object] Empty the buffer and |:read| a |fugitive-object|.
|
||||
When the argument is omitted, this is similar to
|
||||
git-checkout on a work tree file or git-add on a stage
|
||||
file, but without writing anything to disk.
|
||||
|
||||
:{range}Gread [revision]
|
||||
|:read| in a |fugitive-revision| after {range}.
|
||||
:{range}Gread [object] |:read| in a |fugitive-object| after {range}.
|
||||
|
||||
*fugitive-:Gread!*
|
||||
:Gread! [args] Empty the buffer and |:read| the output of a Git
|
||||
@ -179,23 +179,24 @@ that are part of Git repositories).
|
||||
succeeded.
|
||||
|
||||
*fugitive-:Gdiff*
|
||||
:Gdiff [revision] Perform a |vimdiff| against the current file in the
|
||||
given revision. With no argument, the version in the
|
||||
index is used (which means a three-way diff during a
|
||||
merge conflict, making it a git-mergetool
|
||||
alternative). The newer of the two files is placed
|
||||
to the right or bottom, depending on 'diffopt' and
|
||||
the width of the window relative to 'textwidth'. Use
|
||||
|do| and |dp| and write to the index file to simulate
|
||||
"git add --patch". For the three-way diff, there is
|
||||
also d2o and d3o pulling the hunk to the middle from
|
||||
the left or the right window, respectively.
|
||||
:Gdiff [object] Perform a |vimdiff| against the given file, or if a
|
||||
commit is given, the current file in that commit.
|
||||
With no argument, the version in the index is used
|
||||
(which means a three-way diff during a merge conflict,
|
||||
making it a git-mergetool alternative). The newer of
|
||||
the two files is placed to the right or bottom,
|
||||
depending on 'diffopt', and the width of the window
|
||||
relative to 'textwidth'. Use |do| and |dp| and write
|
||||
to the index file to simulate "git add --patch". For
|
||||
the three-way diff, there is also d2o and d3o pulling
|
||||
the hunk to the middle from the left or the right
|
||||
window, respectively.
|
||||
|
||||
*fugitive-:Gsdiff*
|
||||
:Gsdiff [revision] Like |:Gdiff|, but always split horizontally.
|
||||
:Gsdiff [object] Like |:Gdiff|, but always split horizontally.
|
||||
|
||||
*fugitive-:Gvdiff*
|
||||
:Gvdiff [revision] Like |:Gdiff|, but always split vertically.
|
||||
:Gvdiff [object] Like |:Gdiff|, but always split vertically.
|
||||
|
||||
*fugitive-:Gmove*
|
||||
:Gmove {destination} Wrapper around git-mv that renames the buffer
|
||||
@ -246,18 +247,17 @@ that are part of Git repositories).
|
||||
supported by installing rhubarb.vim, available at
|
||||
<https://github.com/tpope/vim-rhubarb>.
|
||||
|
||||
:Gbrowse {revision} Like :Gbrowse, but for a given |fugitive-revision|. A
|
||||
useful value here is -, which ties the URL to the
|
||||
latest commit rather than a volatile branch.
|
||||
:Gbrowse {object} Like :Gbrowse, but for a given |fugitive-object|.
|
||||
|
||||
:Gbrowse [...]@{remote} Force using the given remote rather than the remote
|
||||
for the current branch. The remote is used to
|
||||
determine which GitHub repository to link to.
|
||||
determine which upstream repository to link to.
|
||||
|
||||
:{range}Gbrowse [args] Appends an anchor to the URL that emphasizes the
|
||||
selected lines. You almost certainly want to give a
|
||||
"-" argument in this case to force the URL to include
|
||||
an exact revision.
|
||||
selected lines. This also forces the URL to include a
|
||||
commit rather than a branch name so it remains valid
|
||||
if the file changes. You can give a range of "0" to
|
||||
force this behavior without including an anchor.
|
||||
|
||||
:[range]Gbrowse! [args] Like :Gbrowse, but put the URL on the clipboard rather
|
||||
than opening it.
|
||||
@ -268,26 +268,29 @@ These maps are available everywhere.
|
||||
|
||||
*fugitive-c_CTRL-R_CTRL-G*
|
||||
<C-R><C-G> On the command line, recall the path to the current
|
||||
object (that is, a representation of the object
|
||||
recognized by |:Gedit|).
|
||||
|fugitive-object| (that is, a representation of the
|
||||
object recognized by |:Gedit|).
|
||||
|
||||
*fugitive-y_CTRL-G*
|
||||
["x]y<C-G> Yank the commit SHA and path to the current object.
|
||||
["x]y<C-G> Yank the commit SHA and path to the current
|
||||
|fugitive-object|.
|
||||
|
||||
These maps are available in Git objects.
|
||||
These maps are available in committed Git objects.
|
||||
|
||||
*fugitive-<CR>*
|
||||
<CR> Jump to the revision under the cursor.
|
||||
<CR> Jump to the |fugitive-object| under the cursor.
|
||||
|
||||
*fugitive-o*
|
||||
o Jump to the revision under the cursor in a new split.
|
||||
o Jump to the |fugitive-object| under the cursor in a
|
||||
new split.
|
||||
|
||||
*fugitive-S*
|
||||
S Jump to the revision under the cursor in a new
|
||||
vertical split.
|
||||
S Jump to the |fugitive-object| under the cursor in a
|
||||
new vertical split.
|
||||
|
||||
*fugitive-O*
|
||||
O Jump to the revision under the cursor in a new tab.
|
||||
O Jump to the |fugitive-object| under the cursor in a
|
||||
new tab.
|
||||
|
||||
*fugitive--*
|
||||
- Go to the tree containing the current tree or blob.
|
||||
@ -302,35 +305,32 @@ P Go to the current file in the [count]th parent.
|
||||
*fugitive-C*
|
||||
C Go to the commit containing the current file.
|
||||
|
||||
*fugitive-.*
|
||||
. Start a |:| command line with the current revision
|
||||
prepopulated at the end of the line.
|
||||
|
||||
*fugitive-a*
|
||||
a Show the current tag, commit, or tree in an alternate
|
||||
format.
|
||||
|
||||
SPECIFYING REVISIONS *fugitive-revision*
|
||||
SPECIFYING OBJECTS *fugitive-object* *fugitive-revision*
|
||||
|
||||
Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING
|
||||
REVISIONS" section in the git-rev-parse man page. For commands that accept an
|
||||
optional revision, the default is the file in the index for work tree files
|
||||
and the work tree file for everything else. Example revisions follow.
|
||||
Fugitive objects are either work tree files or Git revisions as defined in the
|
||||
"SPECIFYING REVISIONS" section in the git-rev-parse man page, with a few
|
||||
convenience notations thrown in for good measure. For commands that accept an
|
||||
optional object, the default is the file in the index for work tree files and
|
||||
the work tree file for everything else. Example objects follow.
|
||||
|
||||
Revision Meaning ~
|
||||
Object Meaning ~
|
||||
HEAD .git/HEAD
|
||||
refs/heads/x .git/refs/heads/x
|
||||
@ The commit referenced by @ aka HEAD
|
||||
master^ The parent of the commit referenced by master
|
||||
master: The tree referenced by master
|
||||
./master The file named master in the work tree
|
||||
./master The file named master in the working directory
|
||||
Makefile The file named Makefile in the work tree
|
||||
@^:Makefile The file named Makefile in the parent of HEAD
|
||||
:Makefile The file named Makefile in the index (writable)
|
||||
@:% The current file in HEAD
|
||||
- The current file in HEAD
|
||||
^ The current file in the previous commit
|
||||
~3 The current file 3 commits ago
|
||||
-^ The current file in the previous commit
|
||||
-~3 The current file 3 commits ago
|
||||
: .git/index (Same as |:Gstatus|)
|
||||
:% The current file in the index
|
||||
:1:% The current file's common ancestor during a conflict
|
||||
|
@ -8,26 +8,86 @@ if exists('g:loaded_fugitive')
|
||||
endif
|
||||
let g:loaded_fugitive = 1
|
||||
|
||||
function! s:shellslash(path) abort
|
||||
if &shell =~? 'cmd' || exists('+shellslash') && !&shellslash
|
||||
return tr(a:path, '\', '/')
|
||||
else
|
||||
return a:path
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! FugitiveGitDir(...) abort
|
||||
if !a:0 || a:1 ==# -1
|
||||
return get(b:, 'git_dir', '')
|
||||
elseif type(a:1) == type(0)
|
||||
return getbufvar(a:1, 'git_dir')
|
||||
elseif type(a:1) == type('')
|
||||
return substitute(s:shellslash(a:1), '/$', '', '')
|
||||
return substitute(s:Slash(a:1), '/$', '', '')
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! FugitiveCommonDir(...) abort
|
||||
let dir = FugitiveGitDir(a:0 ? a:1 : -1)
|
||||
if empty(dir)
|
||||
return ''
|
||||
endif
|
||||
return fugitive#CommonDir(dir)
|
||||
endfunction
|
||||
|
||||
function! FugitiveWorkTree(...) abort
|
||||
return FugitiveTreeForGitDir(FugitiveGitDir(a:0 ? a:1 : -1))
|
||||
endfunction
|
||||
|
||||
function! FugitiveReal(...) abort
|
||||
let file = a:0 ? a:1 : @%
|
||||
if file =~# '^\a\a\+:' || a:0 > 1
|
||||
return call('fugitive#Real', [file] + a:000[1:-1])
|
||||
elseif file =~# '^/\|^\a:\|^$'
|
||||
return file
|
||||
else
|
||||
return fnamemodify(file, ':p' . (file =~# '[\/]$' ? '' : ':s?[\/]$??'))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! FugitiveRoute(...) abort
|
||||
return fugitive#Route(a:0 ? a:1 : ':/', FugitiveGitDir(a:0 > 1 ? a:2 : -1))
|
||||
endfunction
|
||||
|
||||
function! FugitivePath(...) abort
|
||||
if 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! FugitiveParse(...) abort
|
||||
let path = s:Slash(a:0 ? a:1 : @%)
|
||||
let vals = matchlist(path, '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
|
||||
if len(vals)
|
||||
return [(vals[2] =~# '^.$' ? ':' : '') . vals[2] . substitute(vals[3], '^/', ':', ''), vals[1]]
|
||||
endif
|
||||
let v:errmsg = 'fugitive: invalid Fugitive URL ' . path
|
||||
throw v:errmsg
|
||||
endfunction
|
||||
|
||||
function! FugitiveConfig(key, ...) abort
|
||||
return fugitive#Config(a:key, FugitiveGitDir(a:0 ? a:1 : -1))
|
||||
endfunction
|
||||
|
||||
function! FugitiveRemoteUrl(...) abort
|
||||
return fugitive#RemoteUrl(a:0 ? a:1 : '', FugitiveGitDir(a:0 > 1 ? a:2 : -1))
|
||||
endfunction
|
||||
|
||||
function! FugitiveHead(...) abort
|
||||
let dir = FugitiveGitDir(a:0 > 1 ? a:2 : -1)
|
||||
if empty(dir)
|
||||
return ''
|
||||
endif
|
||||
return fugitive#Head(a:0 ? a:1 : 0, dir)
|
||||
endfunction
|
||||
|
||||
function! FugitiveStatusline(...) abort
|
||||
if !exists('b:git_dir')
|
||||
return ''
|
||||
endif
|
||||
return fugitive#Statusline()
|
||||
endfunction
|
||||
|
||||
function! FugitiveIsGitDir(path) abort
|
||||
let path = substitute(a:path, '[\/]$', '', '') . '/'
|
||||
return getfsize(path.'HEAD') > 10 && (
|
||||
@ -37,8 +97,8 @@ endfunction
|
||||
|
||||
let s:worktree_for_dir = {}
|
||||
let s:dir_for_worktree = {}
|
||||
function! FugitiveWorkTree(...) abort
|
||||
let dir = substitute(s:shellslash(a:0 ? a:1 : get(b:, 'git_dir', '')), '/$', '', '')
|
||||
function! FugitiveTreeForGitDir(path) abort
|
||||
let dir = a:path
|
||||
if dir =~# '/\.git$'
|
||||
return len(dir) ==# 5 ? '/' : dir[0:-6]
|
||||
endif
|
||||
@ -69,75 +129,8 @@ function! FugitiveWorkTree(...) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! FugitiveReal(...) abort
|
||||
let file = a:0 ? a:1 : @%
|
||||
if file =~? '^fugitive:' || a:0 > 1
|
||||
return call('fugitive#Real', [file] + a:000[1:-1])
|
||||
elseif file =~# '^/\|^\a\+:\|^$'
|
||||
return file
|
||||
else
|
||||
return fnamemodify(file, ':p' . (file =~# '[\/]$' ? '' : ':s?[\/]$??'))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! FugitivePath(...) abort
|
||||
if 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! FugitiveGenerate(...) abort
|
||||
if a:0 && s:shellslash(a:0) =~# '^\%(\a\a\+:\)\=\%(a:\)\=/\|^[~$]'
|
||||
return a:1
|
||||
endif
|
||||
return fugitive#repo(FugitiveGitDir(a:0 > 1 ? a:2 : -1)).translate(a:0 ? a:1 : '', 1)
|
||||
endfunction
|
||||
|
||||
function! FugitiveRoute(...) abort
|
||||
return call('FugitiveGenerate', a:000)
|
||||
endfunction
|
||||
|
||||
function! FugitiveParse(...) abort
|
||||
let path = s:shellslash(a:0 ? a:1 : @%)
|
||||
let vals = matchlist(path, '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40\}\|[0-3]\)\(/.*\)\=$')
|
||||
if len(vals)
|
||||
return [(vals[2] =~# '^.$' ? ':' : '') . vals[2] . substitute(vals[3], '^/', ':', ''), vals[1]]
|
||||
endif
|
||||
let v:errmsg = 'fugitive: invalid Fugitive URL ' . path
|
||||
throw v:errmsg
|
||||
endfunction
|
||||
|
||||
function! FugitiveConfig(key, ...) abort
|
||||
return fugitive#Config(a:key, FugitiveGitDir(a:0 ? a:1 : -1))
|
||||
endfunction
|
||||
|
||||
function! FugitiveRemoteUrl(...) abort
|
||||
return fugitive#RemoteUrl(a:0 ? a:1 : '', FugitiveGitDir(a:0 > 1 ? a:2 : -1))
|
||||
endfunction
|
||||
|
||||
function! FugitiveHead(...) abort
|
||||
let dir = FugitiveGitDir(a:0 > 1 ? a:2 : -1)
|
||||
if empty(dir)
|
||||
return ''
|
||||
endif
|
||||
return fugitive#repo(dir).head(a:0 ? a:1 : 0)
|
||||
endfunction
|
||||
|
||||
function! FugitiveStatusline(...) abort
|
||||
if !exists('b:git_dir')
|
||||
return ''
|
||||
endif
|
||||
return fugitive#Statusline()
|
||||
endfunction
|
||||
|
||||
function! FugitiveTreeForGitDir(path) abort
|
||||
return FugitiveWorkTree(a:path)
|
||||
endfunction
|
||||
|
||||
function! FugitiveExtractGitDir(path) abort
|
||||
let path = s:shellslash(a:path)
|
||||
let path = s:Slash(a:path)
|
||||
if path =~# '^fugitive:'
|
||||
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
|
||||
elseif isdirectory(path)
|
||||
@ -147,7 +140,7 @@ function! FugitiveExtractGitDir(path) abort
|
||||
endif
|
||||
let pre = substitute(matchstr(path, '^\a\a\+\ze:'), '^.', '\u&', '')
|
||||
if len(pre) && exists('*' . pre . 'Real')
|
||||
let path = s:shellslash({pre}Real(path))
|
||||
let path = s:Slash({pre}Real(path))
|
||||
endif
|
||||
let root = resolve(path)
|
||||
if root !=# path
|
||||
@ -207,6 +200,18 @@ function! FugitiveDetect(path) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! FugitiveGenerate(...) abort
|
||||
return call('FugitiveRoute', a:000)
|
||||
endfunction
|
||||
|
||||
function! s:Slash(path) abort
|
||||
if exists('+shellslash')
|
||||
return tr(a:path, '\', '/')
|
||||
else
|
||||
return a:path
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup fugitive
|
||||
autocmd!
|
||||
|
||||
@ -231,14 +236,14 @@ augroup fugitive
|
||||
autocmd FileType gitrebase
|
||||
\ let &l:include = '^\%(pick\|squash\|edit\|reword\|fixup\|drop\|[pserfd]\)\>' |
|
||||
\ if exists('b:git_dir') |
|
||||
\ let &l:includeexpr = 'v:fname =~# ''^\x\{4,40\}$'' ? FugitiveGenerate(v:fname) : ' .
|
||||
\ let &l:includeexpr = 'v:fname =~# ''^\x\{4,40\}$'' ? FugitiveRoute(v:fname) : ' .
|
||||
\ (len(&l:includeexpr) ? &l:includeexpr : 'v:fname') |
|
||||
\ endif |
|
||||
\ let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setl inex= inc='
|
||||
|
||||
autocmd BufReadCmd index{,.lock}
|
||||
\ if FugitiveIsGitDir(expand('<amatch>:p:h')) |
|
||||
\ let b:git_dir = s:shellslash(expand('<amatch>:p:h')) |
|
||||
\ let b:git_dir = s:Slash(expand('<amatch>:p:h')) |
|
||||
\ exe fugitive#BufReadStatus() |
|
||||
\ elseif filereadable(expand('<amatch>')) |
|
||||
\ read <amatch> |
|
||||
|
Reference in New Issue
Block a user