dot_vim
This commit is contained in:
parent
f0510126ba
commit
7a7c647c22
212 changed files with 30625 additions and 30625 deletions
73
dot_vim/plugin/AppleT.vim
Normal file
73
dot_vim/plugin/AppleT.vim
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
function! AppleT(name)
|
||||
python << EOF
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import vim
|
||||
|
||||
def walkIt(search):
|
||||
fullpath = os.path.expanduser(set_path)
|
||||
fullsearch = ".*%s.*" % ".*".join(search)
|
||||
fullsearch = re.sub(" ","[/.]", fullsearch)
|
||||
bsearch = re.sub(" ",".*[/.].*", search)
|
||||
exactsearch = "%s" % bsearch
|
||||
exclude = re.compile("\.quer$|\.resp$|\.pyc$")
|
||||
ignoredirs = [".svn", "_site-packages"]
|
||||
fullmatch = re.compile(fullsearch, re.I)
|
||||
exactmatch = re.compile(exactsearch, re.I)
|
||||
length = len(fullpath)
|
||||
|
||||
results = []
|
||||
exactresults = []
|
||||
|
||||
for root, dirs, files in os.walk(set_path):
|
||||
for x in ignoredirs:
|
||||
if x in dirs:
|
||||
dirs.remove(x)
|
||||
for f in files:
|
||||
filename = os.path.join(root,f)
|
||||
if exclude.search(filename):
|
||||
pass
|
||||
elif exactmatch.search(filename):
|
||||
exactresults.append("%s" % filename)
|
||||
elif fullmatch.search(filename):
|
||||
results.append("%s" % filename)
|
||||
|
||||
if len(results) == 0:
|
||||
return
|
||||
|
||||
def cmplen(x,y):
|
||||
return cmp(len(x), len(y))
|
||||
|
||||
results.sort(cmplen)
|
||||
exactresults.sort(cmplen)
|
||||
results = exactresults + results
|
||||
|
||||
for i, a in enumerate(results):
|
||||
print "%d: %s" % (i + 1, a[length:])
|
||||
|
||||
which = vim.eval('input("Which? ")')
|
||||
if re.match("^[0-9]+$", which) == None:
|
||||
return
|
||||
which = int(which) - 1
|
||||
vim.command("tabnew " + results[which])
|
||||
|
||||
thingtosearch = vim.eval("expand(a:name)")
|
||||
walkIt(thingtosearch)
|
||||
|
||||
EOF
|
||||
endfunction
|
||||
|
||||
function! AppleTSetPath(path)
|
||||
python << EOF
|
||||
import vim
|
||||
set_path = vim.eval("expand(a:path)")
|
||||
EOF
|
||||
endfunction
|
||||
|
||||
if !exists(":AppleTSetPath")
|
||||
command! -nargs=+ AppleTSetPath :call AppleTSetPath(<q-args>)
|
||||
endif
|
||||
if !exists(":CmdT")
|
||||
command! -nargs=+ CmdT :call AppleT(<q-args>)
|
||||
endif
|
||||
840
dot_vim/plugin/a.vim
Normal file
840
dot_vim/plugin/a.vim
Normal file
File diff suppressed because it is too large
Load diff
70
dot_vim/plugin/bclose.vim
Normal file
70
dot_vim/plugin/bclose.vim
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
if exists("loaded_bclosePlugin")
|
||||
finish
|
||||
endif
|
||||
if (v:progname == "ex")
|
||||
finish
|
||||
endif
|
||||
let loaded_bclosePlugin = 1
|
||||
|
||||
|
||||
"here is a more exotic version of my original Kwbd script
|
||||
"delete the buffer; keep windows; create a scratch buffer if no buffers left
|
||||
function s:Kwbd(kwbdStage)
|
||||
if(a:kwbdStage == 1)
|
||||
if(!buflisted(winbufnr(0)))
|
||||
bd!
|
||||
return
|
||||
endif
|
||||
let s:kwbdBufNum = bufnr("%")
|
||||
let s:kwbdWinNum = winnr()
|
||||
windo call s:Kwbd(2)
|
||||
execute s:kwbdWinNum . 'wincmd w'
|
||||
let s:buflistedLeft = 0
|
||||
let s:bufFinalJump = 0
|
||||
let l:nBufs = bufnr("$")
|
||||
let l:i = 1
|
||||
while(l:i <= l:nBufs)
|
||||
if(l:i != s:kwbdBufNum)
|
||||
if(buflisted(l:i))
|
||||
let s:buflistedLeft = s:buflistedLeft + 1
|
||||
else
|
||||
if(bufexists(l:i) && !strlen(bufname(l:i)) && !s:bufFinalJump)
|
||||
let s:bufFinalJump = l:i
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
let l:i = l:i + 1
|
||||
endwhile
|
||||
if(!s:buflistedLeft)
|
||||
if(s:bufFinalJump)
|
||||
windo if(buflisted(winbufnr(0))) | execute "b! " . s:bufFinalJump | endif
|
||||
else
|
||||
enew
|
||||
let l:newBuf = bufnr("%")
|
||||
windo if(buflisted(winbufnr(0))) | execute "b! " . l:newBuf | endif
|
||||
endif
|
||||
execute s:kwbdWinNum . 'wincmd w'
|
||||
endif
|
||||
if(buflisted(s:kwbdBufNum) || s:kwbdBufNum == bufnr("%"))
|
||||
execute "bd! " . s:kwbdBufNum
|
||||
endif
|
||||
if(!s:buflistedLeft)
|
||||
set buflisted
|
||||
set bufhidden=delete
|
||||
set buftype=nofile
|
||||
setlocal noswapfile
|
||||
endif
|
||||
else
|
||||
if(bufnr("%") == s:kwbdBufNum)
|
||||
let prevbufvar = bufnr("#")
|
||||
if(prevbufvar > 0 && buflisted(prevbufvar) && prevbufvar != s:kwbdBufNum)
|
||||
b #
|
||||
else
|
||||
bn
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
command! Kwbd call <SID>Kwbd(1)
|
||||
nnoremap <silent> <Plug>Kwbd :<C-u>Kwbd<CR>
|
||||
449
dot_vim/plugin/camelcasemotion.vim
Normal file
449
dot_vim/plugin/camelcasemotion.vim
Normal file
|
|
@ -0,0 +1,449 @@
|
|||
" camelcasemotion.vim: Mappings for motion through CamelCaseWords and
|
||||
" underscore_notation.
|
||||
"
|
||||
" DESCRIPTION: {{{1
|
||||
" VIM provides many built-in motions, e.g. to move to the next word, or
|
||||
" end of the current word. Most programming languages use either CamelCase
|
||||
" ("anIdentifier") or underscore_notation ("an_identifier") naming
|
||||
" conventions for identifiers. The best way to navigate inside those
|
||||
" identifiers using VIM built-in motions is the '[count]f{char}' motion, i.e.
|
||||
" 'f<uppercase char>' or 'f_', respectively. But we can make this easier:
|
||||
"
|
||||
" This script defines motions ',w', ',b' and ',e' (similar to 'w', 'b', 'e'),
|
||||
" which do not move word-wise (forward/backward), but Camel-wise; i.e. to word
|
||||
" boundaries and uppercase letters. The motions also work on underscore
|
||||
" notation, where words are delimited by underscore ('_') characters.
|
||||
" From here on, both CamelCase and underscore_notation entities are referred
|
||||
" to as "words" (in double quotes). Just like with the regular motions, a
|
||||
" [count] can be prepended to move over multiple "words" at once.
|
||||
" Outside of "words" (e.g. in non-keyword characters like // or ;), the new
|
||||
" motions move just like the regular motions.
|
||||
"
|
||||
" VIM provides a built-in text object called 'inner word' ('iw'), which works
|
||||
" in operator-pending and visual mode. Analog to that, this script defines
|
||||
" inner "word" motions 'i,w', 'i,b' and 'i,e', which select the "word" (or
|
||||
" multiple "words" if a [count] is given) where the cursor is located.
|
||||
"
|
||||
" USAGE:
|
||||
" Use the new motions ',w', ',b' and ',e' in normal mode, operator-pending
|
||||
" mode (cp. :help operator), and visual mode. For example, type 'bc,w' to
|
||||
" change 'Camel' in 'CamelCase' to something else.
|
||||
"
|
||||
" EXAMPLE: motions
|
||||
" Given the following CamelCase identifiers in a source code fragment:
|
||||
" set Script31337PathAndNameWithoutExtension11=%~dpn0
|
||||
" set Script31337PathANDNameWITHOUTExtension11=%~dpn0
|
||||
" and the corresponding identifiers in underscore_notation:
|
||||
" set script_31337_path_and_name_without_extension_11=%~dpn0
|
||||
" set SCRIPT_31337_PATH_AND_NAME_WITHOUT_EXTENSION_11=%~dpn0
|
||||
"
|
||||
" ,w moves to ([x] is cursor position): [s]et, [s]cript, [3]1337, [p]ath,
|
||||
" [a]nd, [n]ame, [w]ithout, [e]xtension, [1]1, [d]pn0, dpn[0], [s]et
|
||||
" ,b moves to: [d]pn0, [1]1, [e]xtension, [w]ithout, ...
|
||||
" ,e moves to: se[t], scrip[t], 3133[7], pat[h], an[d], nam[e], withou[t],
|
||||
" extensio[n], 1[1], dpn[0]
|
||||
"
|
||||
" EXAMPLE: inner motions
|
||||
" Given the following identifier, with the cursor positioned at [x]:
|
||||
" script_31337_path_and_na[m]e_without_extension_11
|
||||
"
|
||||
" v3i,w selects script_31337_path_and_[name_without_extension_]11
|
||||
" v3i,b selects script_31337_[path_and_name]_without_extension_11
|
||||
" v3i,e selects script_31337_path_and_[name_without_extension]_11
|
||||
" Instead of visual mode, you can also use c3i,w to change, d3i,w to delete,
|
||||
" gU3i,w to upper-case, and so on.
|
||||
"
|
||||
" INSTALLATION: {{{1
|
||||
" Put the script into your user or system VIM plugin directory (e.g.
|
||||
" ~/.vim/plugin).
|
||||
"
|
||||
" DEPENDENCIES:
|
||||
" - Requires VIM 7.0 or higher.
|
||||
"
|
||||
" CONFIGURATION:
|
||||
" If you want to use different mappings, map your keys to the
|
||||
" <Plug>CamelCaseMotion_? mapping targets _before_ sourcing this script
|
||||
" (e.g. in your .vimrc).
|
||||
"
|
||||
" Example: Replace the default 'w', 'b' and 'e' mappings instead of defining
|
||||
" additional mappings ',w', ',b' and ',e':
|
||||
" map <silent> w <Plug>CamelCaseMotion_w
|
||||
" map <silent> b <Plug>CamelCaseMotion_b
|
||||
" map <silent> e <Plug>CamelCaseMotion_e
|
||||
"
|
||||
" Example: Replace default 'iw' text-object and define 'ib' and 'ie' motions:
|
||||
" omap <silent> iw <Plug>CamelCaseMotion_iw
|
||||
" vmap <silent> iw <Plug>CamelCaseMotion_iw
|
||||
" omap <silent> ib <Plug>CamelCaseMotion_ib
|
||||
" vmap <silent> ib <Plug>CamelCaseMotion_ib
|
||||
" omap <silent> ie <Plug>CamelCaseMotion_ie
|
||||
" vmap <silent> ie <Plug>CamelCaseMotion_ie
|
||||
"
|
||||
" LIMITATIONS:
|
||||
"
|
||||
" ASSUMPTIONS:
|
||||
"
|
||||
" KNOWN PROBLEMS:
|
||||
" - A degenerate CamelCaseWord containing '\U\u\d' (e.g. "MaP1Roblem")
|
||||
" confuses the operator-pending and visual mode ,e mapping if 'selection' is
|
||||
" not set to "exclusive". It'll skip "P" and select "P1" in one step. As a
|
||||
" workaround, use ',w' instead of ',e'; those two mappings have the same
|
||||
" effect inside CamelCaseWords, anyway.
|
||||
" - The operator-pending and visual mode ,e mapping doesn't work properly when
|
||||
" it reaches the end of the buffer; the final character of the moved-over
|
||||
" "word" remains. As a workaround, use the default 'e' motion instead of
|
||||
" ',e'.
|
||||
" - When the VIM setting 'selection' is not set to "exclusive", a
|
||||
" forward-backward combination in visual mode (e.g. 'v,w,b') selects one
|
||||
" additional character to the left, instead of only the character where the
|
||||
" motion started. Likewise, extension of the visual selection from the front
|
||||
" end is off by one additional character.
|
||||
"
|
||||
" TODO:
|
||||
"
|
||||
" Copyright: (C) 2007-2008 by Ingo Karkat
|
||||
" The VIM LICENSE applies to this script; see ':help copyright'.
|
||||
"
|
||||
" Source: Based on vimtip #1016 by Anthony Van Ham.
|
||||
" Maintainer: Ingo Karkat <ingo@karkat.de>
|
||||
" REVISION DATE REMARKS {{{1
|
||||
" 1.40.017 19-May-2008 BF: Now using :normal! to be independent from
|
||||
" any user mappings. Thanks to Neil Walker for the
|
||||
" patch.
|
||||
" 1.40.016 28-Apr-2008 BF: Wrong forward motion stop at the second
|
||||
" digit if a word starts with multiple numbers
|
||||
" (e.g. 1234.56789). Thanks to Wasim Ahmed for
|
||||
" reporting this.
|
||||
" 1.40.015 24-Apr-2008 ENH: Added inner "word" text objects 'i,w' etc.
|
||||
" that work analoguous to the built-in 'iw' text
|
||||
" object. Thanks to David Kotchan for this
|
||||
" suggestion.
|
||||
" 1.30.014 20-Apr-2008 The motions now also stop at non-keyword
|
||||
" boundaries, just like the regular motions. This
|
||||
" has no effect inside a CamelCaseWord or inside
|
||||
" underscore_notation, but it makes the motions
|
||||
" behave like the regular motions (which is
|
||||
" important if you replace the default motions).
|
||||
" Thanks to Mun Johl for reporting this.
|
||||
" Now using non-capturing parentheses \%() in the
|
||||
" patterns.
|
||||
" 1.30.013 09-Apr-2008 Refactored away s:VisualCamelCaseMotion().
|
||||
" Allowing users to use mappings different than
|
||||
" ,w ,b ,e by defining <Plug>CamelCaseMotion_?
|
||||
" target mappings. This can even be used to
|
||||
" replace the default 'w', 'b' and 'e' mappings,
|
||||
" as suggested by Mun Johl.
|
||||
" Mappings are now created in a generic function.
|
||||
" Now requires VIM 7.0 or higher.
|
||||
" 1.20.012 02-Jun-2007 BF: Corrected motions through mixed
|
||||
" CamelCase_and_UnderScore words by re-ordering
|
||||
" and narrowing the search patterns.
|
||||
" 1.20.011 02-Jun-2007 Thanks again to Joseph Barker for discussing the
|
||||
" complicated visual mode mapping on the vim-dev
|
||||
" mailing list and coming up with a great
|
||||
" simplification:
|
||||
" Removed s:CheckForChangesToTheSelectionSetting().
|
||||
" Introduced s:VisualCamelCaseMotion(), which
|
||||
" handles the differences depending on the
|
||||
" 'selection' setting.
|
||||
" Visual mode mappings now directly map to the
|
||||
" s:VisualCamelCaseMotion() function; no mark is
|
||||
" clobbered, the complex mapping with the inline
|
||||
" expression has been retired.
|
||||
" 1.20.010 29-May-2007 BF: The operator-pending and visual mode ,e
|
||||
" mapping doesn't work properly when it reaches
|
||||
" the end of line; the final character of the
|
||||
" moved-over "word" remains. Fixed this problem
|
||||
" unless the "word" is at the very end of the
|
||||
" buffer.
|
||||
" ENH: The visual mode motions now also (mostly)
|
||||
" work with the (default) setting
|
||||
" 'set selection=inclusive', instead of selecting
|
||||
" one character too much.
|
||||
" ENH: All mappings will check for changes to the
|
||||
" 'selection' setting and remap the visual mode
|
||||
" mappings via function
|
||||
" s:SetupVisualModeMappings(). We cannot rely on
|
||||
" the setting while sourcing camelcasemotion.vim
|
||||
" because the mswin.vim script may be sourced
|
||||
" afterwards, and its 'behave mswin' changes
|
||||
" 'selection'.
|
||||
" Refactored the arguments of function
|
||||
" s:CamelCaseMotion(...).
|
||||
" 1.10.009 28-May-2007 BF: Degenerate CamelCaseWords that consist of
|
||||
" only a single uppercase letter (e.g. "P" in
|
||||
" "MapPRoblem") are skipped by all motions. Thanks
|
||||
" to Joseph Barker for reporting this.
|
||||
" BF: In CamelCaseWords that consist of uppercase
|
||||
" letters followed by decimals (e.g.
|
||||
" "MyUPPER123Problem", the uppercase "word" is
|
||||
" skipped by all motions.
|
||||
" 1.10.008 28-May-2007 Incorporated major improvements and
|
||||
" simplifications done by Joseph Barker:
|
||||
" Operator-pending and visual mode motions now
|
||||
" accept [count] of more than 9.
|
||||
" Visual selections can now be extended from
|
||||
" either end.
|
||||
" Instead of misusing the :[range], the special
|
||||
" variable v:count1 is used. Custom commands are
|
||||
" not needed anymore.
|
||||
" Operator-pending and visual mode mappings are
|
||||
" now generic: There's only a single mapping for
|
||||
" ,w that can be repeated, rather than having a
|
||||
" separate mapping for 1,w 2,w 3,w ...
|
||||
" 1.00.007 22-May-2007 Added documentation for publication.
|
||||
" 006 20-May-2007 BF: visual mode [1,2,3],e on pure CamelCase
|
||||
" mistakenly marks [2,4,6] words. If the cursor is
|
||||
" on a uppercase letter, the search pattern
|
||||
" '\u\l\+' doesn't match at the cursor position,
|
||||
" so another match won. Changed search pattern
|
||||
" from '\l\+',
|
||||
" 005 16-May-2007 Added support for underscore notation.
|
||||
" Added support for "forward to end of word"
|
||||
" (',e') motion.
|
||||
" 004 16-May-2007 Improved search pattern so that
|
||||
" UppercaseWORDSInBetween and digits are handled,
|
||||
" too.
|
||||
" 003 15-May-2007 Changed mappings from <Leader>w to ,w;
|
||||
" other \w mappings interfere here, because it's
|
||||
" irritating when the cursor jump doesn't happen
|
||||
" immediately, because VIM waits whether the
|
||||
" mapping is complete. ,w is faster to type that
|
||||
" \w (and, because of the left-right touch,
|
||||
" preferred over gw).
|
||||
" Added visual mode mappings.
|
||||
" 0.02 15-Feb-2006 BF: missing <SID> for omaps.
|
||||
" 0.01 11-Oct-2005 file creation
|
||||
|
||||
" Avoid installing twice or when in compatible mode
|
||||
if exists("loaded_camelcasemotion") || (v:version < 700)
|
||||
finish
|
||||
endif
|
||||
let loaded_camelcasemotion = 1
|
||||
" }}}1
|
||||
|
||||
"- functions ------------------------------------------------------------------"
|
||||
function! s:CamelCaseMove( direction, count, mode ) " {{{1
|
||||
" Note: There is no inversion of the regular expression character class
|
||||
" 'keyword character' (\k). We need an inversion "non-keyword" defined as
|
||||
" "any non-whitespace character that is not a keyword character (e.g.
|
||||
" [!@#$%^&*()]. This can be specified via a non-whitespace character in
|
||||
" whose place no keyword character matches (\k\@!\S).
|
||||
|
||||
"echo "count is " . a:count
|
||||
let l:i = 0
|
||||
while l:i < a:count
|
||||
if a:direction == 'e'
|
||||
" "Forward to end" motion.
|
||||
"call search( '\>\|\(\a\|\d\)\+\ze_', 'We' )
|
||||
" end of ...
|
||||
" number | ACRONYM followed by CamelCase or number | CamelCase | underscore_notation | non-keyword | word
|
||||
call search( '\d\+\|\u\+\ze\%(\u\l\|\d\)\|\u\l\+\|\%(\a\|\d\)\+\ze_\|\%(\k\@!\S\)\+\|\%(_\@!\k\)\+\>', 'We' )
|
||||
" Note: word must be defined as '\k\>'; '\>' on its own somehow
|
||||
" dominates over the previous branch. Plus, \k must exclude the
|
||||
" underscore, or a trailing one will be incorrectly moved over:
|
||||
" '\%(_\@!\k\)'.
|
||||
if a:mode == 'o'
|
||||
" Note: Special additional treatment for operator-pending mode
|
||||
" "forward to end" motion.
|
||||
" The difference between normal mode, operator-pending and visual
|
||||
" mode is that in the latter two, the motion must go _past_ the
|
||||
" final "word" character, so that all characters of the "word" are
|
||||
" selected. This is done by appending a 'l' motion after the
|
||||
" search for the next "word".
|
||||
"
|
||||
" In operator-pending mode, the 'l' motion only works properly
|
||||
" at the end of the line (i.e. when the moved-over "word" is at
|
||||
" the end of the line) when the 'l' motion is allowed to move
|
||||
" over to the next line. Thus, the 'l' motion is added
|
||||
" temporarily to the global 'whichwrap' setting.
|
||||
" Without this, the motion would leave out the last character in
|
||||
" the line. I've also experimented with temporarily setting
|
||||
" "set virtualedit=onemore" , but that didn't work.
|
||||
let l:save_ww = &whichwrap
|
||||
set whichwrap+=l
|
||||
normal! l
|
||||
let &whichwrap = l:save_ww
|
||||
endif
|
||||
else
|
||||
" Forward (a:direction == '') and backward (a:direction == 'b')
|
||||
" motion.
|
||||
|
||||
let l:direction = (a:direction == 'w' ? '' : a:direction)
|
||||
|
||||
" CamelCase: Jump to beginning of either (start of word, Word, WORD,
|
||||
" 123).
|
||||
" Underscore_notation: Jump to the beginning of an underscore-separated
|
||||
" word or number.
|
||||
"call search( '\<\|\u', 'W' . l:direction )
|
||||
"call search( '\<\|\u\(\l\+\|\u\+\ze\u\)\|\d\+', 'W' . l:direction )
|
||||
"call search( '\<\|\u\(\l\+\|\u\+\ze\u\)\|\d\+\|_\zs\(\a\|\d\)\+', 'W' . l:direction )
|
||||
" beginning of ...
|
||||
" word | empty line | non-keyword after whitespaces | non-whitespace after word | number | ACRONYM followed by CamelCase or number | CamelCase | underscore followed by ACRONYM, Camel, lowercase or number
|
||||
call search( '\<\D\|^$\|\%(^\|\s\)\+\zs\k\@!\S\|\>\S\|\d\+\|\u\+\ze\%(\u\l\|\d\)\|\u\l\+\|_\zs\%(\u\+\|\u\l\+\|\l\+\|\d\+\)', 'W' . l:direction )
|
||||
" Note: word must be defined as '\<\D' to avoid that a word like
|
||||
" 1234Test is moved over as [1][2]34[T]est instead of [1]234[T]est
|
||||
" because \< matches with zero width, and \d\+ will then start
|
||||
" matching '234'. To fix that, we make \d\+ be solely responsible
|
||||
" for numbers by taken this away from \< via \<\D. (An alternative
|
||||
" would be to replace \d\+ with \D\%#\zs\d\+, but that one is more
|
||||
" complex.) All other branches are not affected, because they match
|
||||
" multiple characters and not the same character multiple times.
|
||||
endif
|
||||
let l:i = l:i + 1
|
||||
endwhile
|
||||
endfunction
|
||||
" }}}1
|
||||
|
||||
function! s:CamelCaseMotion( direction, count, mode ) " {{{1
|
||||
"*******************************************************************************
|
||||
"* PURPOSE:
|
||||
" Perform the motion over CamelCaseWords or underscore_notation.
|
||||
"* ASSUMPTIONS / PRECONDITIONS:
|
||||
" none
|
||||
"* EFFECTS / POSTCONDITIONS:
|
||||
" Move cursor / change selection.
|
||||
"* INPUTS:
|
||||
" a:direction one of 'w', 'b', 'e'
|
||||
" a:count number of "words" to move over
|
||||
" a:mode one of 'n', 'o', 'v', 'iv' (latter one is a special visual mode
|
||||
" when inside the inner "word" text objects.
|
||||
"* RETURN VALUES:
|
||||
" none
|
||||
"*******************************************************************************
|
||||
" Visual mode needs special preparations and postprocessing;
|
||||
" normal and operator-pending mode breeze through to s:CamelCaseMove().
|
||||
|
||||
if a:mode == 'v'
|
||||
" Visual mode was left when calling this function. Reselecting the current
|
||||
" selection returns to visual mode and allows to call search() and issue
|
||||
" normal mode motions while staying in visual mode.
|
||||
normal! gv
|
||||
endif
|
||||
if a:mode == 'v' || a:mode == 'iv'
|
||||
|
||||
" Note_1a:
|
||||
if &selection != 'exclusive' && a:direction == 'w'
|
||||
normal! l
|
||||
endif
|
||||
endif
|
||||
|
||||
call s:CamelCaseMove( a:direction, a:count, a:mode )
|
||||
|
||||
if a:mode == 'v' || a:mode == 'iv'
|
||||
" Note: 'selection' setting.
|
||||
if &selection == 'exclusive' && a:direction == 'e'
|
||||
" When set to 'exclusive', the "forward to end" motion (',e') does not
|
||||
" include the last character of the moved-over "word". To include that, an
|
||||
" additional 'l' motion is appended to the motion; similar to the
|
||||
" special treatment in operator-pending mode.
|
||||
normal! l
|
||||
elseif &selection != 'exclusive' && a:direction != 'e'
|
||||
" Note_1b:
|
||||
" The forward and backward motions move to the beginning of the next "word".
|
||||
" When 'selection' is set to 'inclusive' or 'old', this is one character too far.
|
||||
" The appended 'h' motion undoes this. Because of this backward step,
|
||||
" though, the forward motion finds the current "word" again, and would
|
||||
" be stuck on the current "word". An 'l' motion before the CamelCase
|
||||
" motion (see Note_1a) fixes that.
|
||||
normal! h
|
||||
end
|
||||
endif
|
||||
endfunction
|
||||
" }}}1
|
||||
|
||||
function! s:CamelCaseInnerMotion( direction, count ) " {{{1
|
||||
" If the cursor is positioned on the first character of a CamelWord, the
|
||||
" backward motion would move to the previous word, which would result in a
|
||||
" wrong selection. To fix this, first move the cursor to the right, so that
|
||||
" the backward motion definitely will cover the current "word" under the
|
||||
" cursor.
|
||||
normal! l
|
||||
|
||||
" Move "word" backwards, enter visual mode, then move "word" forward. This
|
||||
" selects the inner "word" in visual mode; the operator-pending mode takes
|
||||
" this selection as the area covered by the motion.
|
||||
if a:direction == 'b'
|
||||
" Do not do the selection backwards, because the backwards "word" motion
|
||||
" in visual mode + selection=inclusive has an off-by-one error.
|
||||
call s:CamelCaseMotion( 'b', a:count, 'n' )
|
||||
normal! v
|
||||
" We decree that 'b' is the opposite of 'e', not 'w'. This makes more
|
||||
" sense at the end of a line and for underscore_notation.
|
||||
call s:CamelCaseMotion( 'e', a:count, 'iv' )
|
||||
else
|
||||
call s:CamelCaseMotion( 'b', 1, 'n' )
|
||||
normal! v
|
||||
call s:CamelCaseMotion( a:direction, a:count, 'iv' )
|
||||
endif
|
||||
endfunction
|
||||
" }}}1
|
||||
|
||||
"- mappings -------------------------------------------------------------------
|
||||
" The count is passed into the function through the special variable 'v:count1',
|
||||
" which is easier than misusing the :[range] that :call supports.
|
||||
" <C-U> is used to delete the unused range.
|
||||
" Another option would be to use a custom 'command! -count=1', but that doesn't
|
||||
" work with the normal mode mapping: When a count is typed before the mapping,
|
||||
" the ':' will convert a count of 3 into ':.,+2MyCommand', but ':3MyCommand'
|
||||
" would be required to use -count and <count>.
|
||||
"
|
||||
" We do not provide the fourth "backward to end" motion (,E), because it is
|
||||
" seldomly used.
|
||||
|
||||
function! s:CreateMotionMappings() "{{{1
|
||||
" Create mappings according to this template:
|
||||
" (* stands for the mode [nov], ? for the underlying motion [wbe].)
|
||||
"
|
||||
" *noremap <script> <Plug>CamelCaseMotion_? :<C-U>call <SID>CamelCaseMotion('?',v:count1,'*')<CR>
|
||||
" if ! hasmapto('<Plug>CamelCaseMotion_?', '*')
|
||||
" *map <silent> ,? <Plug>CamelCaseMotion_?
|
||||
" endif
|
||||
|
||||
for l:mode in ['n', 'o', 'v']
|
||||
for l:motion in ['w', 'b', 'e']
|
||||
let l:targetMapping = '<Plug>CamelCaseMotion_' . l:motion
|
||||
execute l:mode . 'noremap <script> ' . l:targetMapping . ' :<C-U>call <SID>CamelCaseMotion(''' . l:motion . ''',v:count1,''' . l:mode . ''')<CR>'
|
||||
if ! hasmapto(l:targetMapping, l:mode)
|
||||
execute l:mode . 'map <silent> ,' . l:motion . ' ' . l:targetMapping
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
" }}}1
|
||||
|
||||
" To create a text motion, a mapping for operator-pending mode needs to be
|
||||
" defined. This mapping should move the cursor according to the implemented
|
||||
" motion, or mark the covered text via a visual selection. As inner text motions
|
||||
" need to mark both to the left and right of the cursor position, the visual
|
||||
" selection needs to be used.
|
||||
"
|
||||
" VIM's built-in inner text objects also work in visual mode; they have
|
||||
" different behavior depending on whether visual mode has just been entered or
|
||||
" whether text has already been selected.
|
||||
" We deviate from that and always override the existing selection.
|
||||
function! s:CreateInnerMotionMappings() "{{{1
|
||||
" Create mappings according to this template:
|
||||
" (* stands for the mode [ov], ? for the underlying motion [wbe].)
|
||||
"
|
||||
" *noremap <script> <Plug>CamelCaseMotion_i? :<C-U>call <SID>CamelCaseInnerMotion('?',v:count1)<CR>
|
||||
" if ! hasmapto('<Plug>CamelCaseInnerMotion_i?', '*')
|
||||
" *map <silent> i,? <Plug>CamelCaseInnerMotion_i?
|
||||
" endif
|
||||
|
||||
for l:mode in ['o', 'v']
|
||||
for l:motion in ['w', 'b', 'e']
|
||||
let l:targetMapping = '<Plug>CamelCaseMotion_i' . l:motion
|
||||
execute l:mode . 'noremap <script> ' . l:targetMapping . ' :<C-U>call <SID>CamelCaseInnerMotion(''' . l:motion . ''',v:count1)<CR>'
|
||||
if ! hasmapto(l:targetMapping, l:mode)
|
||||
execute l:mode . 'map <silent> i,' . l:motion . ' ' . l:targetMapping
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
" }}}1
|
||||
|
||||
call s:CreateMotionMappings()
|
||||
call s:CreateInnerMotionMappings()
|
||||
|
||||
" vim: set sts=4 sw=4 noexpandtab ff=unix fdm=marker :
|
||||
16
dot_vim/plugin/cocoa.vim
Normal file
16
dot_vim/plugin/cocoa.vim
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
" File: cocoa.vim
|
||||
" Author: Michael Sanders msanders [at] gmail [dot] com
|
||||
if exists('s:did_cocoa') || &cp || version < 700
|
||||
finish
|
||||
endif
|
||||
let s:did_cocoa = 1
|
||||
|
||||
" These have to load after the normal ftplugins to override the defaults; I'd
|
||||
" like to put this in ftplugin/objc_cocoa_mappings.vim, but that doesn't seem
|
||||
" to work..
|
||||
au FileType objc ru after/syntax/objc_enhanced.vim
|
||||
\| let b:match_words = '@\(implementation\|interface\):@end'
|
||||
\| setl inc=^\s*#\s*import omnifunc=objc#cocoacomplete#Complete
|
||||
\| if globpath(expand('<afile>:p:h'), '*.xcodeproj') != '' |
|
||||
\ setl makeprg=open\ -a\ xcode\ &&\ osascript\ -e\ 'tell\ app\ \"Xcode\"\ to\ build'
|
||||
\| endif
|
||||
166
dot_vim/plugin/cscope_maps.vim
Normal file
166
dot_vim/plugin/cscope_maps.vim
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" CSCOPE settings for vim
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
"
|
||||
" This file contains some boilerplate settings for vim's cscope interface,
|
||||
" plus some keyboard mappings that I've found useful.
|
||||
"
|
||||
" USAGE:
|
||||
" -- vim 6: Stick this file in your ~/.vim/plugin directory (or in a
|
||||
" 'plugin' directory in some other directory that is in your
|
||||
" 'runtimepath'.
|
||||
"
|
||||
" -- vim 5: Stick this file somewhere and 'source cscope.vim' it from
|
||||
" your ~/.vimrc file (or cut and paste it into your .vimrc).
|
||||
"
|
||||
" NOTE:
|
||||
" These key maps use multiple keystrokes (2 or 3 keys). If you find that vim
|
||||
" keeps timing you out before you can complete them, try changing your timeout
|
||||
" settings, as explained below.
|
||||
"
|
||||
" Happy cscoping,
|
||||
"
|
||||
" Jason Duell jduell@alumni.princeton.edu 2002/3/7
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
|
||||
" This tests to see if vim was configured with the '--enable-cscope' option
|
||||
" when it was compiled. If it wasn't, time to recompile vim...
|
||||
if has("cscope")
|
||||
|
||||
""""""""""""" Standard cscope/vim boilerplate
|
||||
set nocsverb
|
||||
|
||||
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
|
||||
set cscopetag
|
||||
|
||||
" check cscope for definition of a symbol before checking ctags: set to 1
|
||||
" if you want the reverse search order.
|
||||
set csto=0
|
||||
|
||||
" add any cscope database in current directory
|
||||
if filereadable("cscope.out")
|
||||
cs add cscope.out
|
||||
" else add the database pointed to by environment variable
|
||||
elseif $CSCOPE_DB != ""
|
||||
cs add $CSCOPE_DB
|
||||
endif
|
||||
|
||||
" show msg when any other cscope db added
|
||||
set cscopeverbose
|
||||
|
||||
|
||||
""""""""""""" My cscope/vim key mappings
|
||||
"
|
||||
" The following maps all invoke one of the following cscope search types:
|
||||
"
|
||||
" 's' symbol: find all references to the token under cursor
|
||||
" 'g' global: find global definition(s) of the token under cursor
|
||||
" 'c' calls: find all calls to the function name under cursor
|
||||
" 't' text: find all instances of the text under cursor
|
||||
" 'e' egrep: egrep search for the word under cursor
|
||||
" 'f' file: open the filename under cursor
|
||||
" 'i' includes: find files that include the filename under cursor
|
||||
" 'd' called: find functions that function under cursor calls
|
||||
"
|
||||
" Below are three sets of the maps: one set that just jumps to your
|
||||
" search result, one that splits the existing vim window horizontally and
|
||||
" diplays your search result in the new window, and one that does the same
|
||||
" thing, but does a vertical split instead (vim 6 only).
|
||||
"
|
||||
" I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's
|
||||
" unlikely that you need their default mappings (CTRL-\'s default use is
|
||||
" as part of CTRL-\ CTRL-N typemap, which basically just does the same
|
||||
" thing as hitting 'escape': CTRL-@ doesn't seem to have any default use).
|
||||
" If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all
|
||||
" of these maps to use other keys. One likely candidate is 'CTRL-_'
|
||||
" (which also maps to CTRL-/, which is easier to type). By default it is
|
||||
" used to switch between Hebrew and English keyboard mode.
|
||||
"
|
||||
" All of the maps involving the <cfile> macro use '^<cfile>$': this is so
|
||||
" that searches over '#include <time.h>" return only references to
|
||||
" 'time.h', and not 'sys/time.h', etc. (by default cscope will return all
|
||||
" files that contain 'time.h' as part of their name).
|
||||
|
||||
|
||||
" To do the first type of search, hit 'CTRL-\', followed by one of the
|
||||
" cscope search types above (s,g,c,t,e,f,i,d). The result of your cscope
|
||||
" search will be displayed in the current window. You can use CTRL-T to
|
||||
" go back to where you were before the search.
|
||||
"
|
||||
|
||||
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
|
||||
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
|
||||
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
|
||||
|
||||
|
||||
" Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type
|
||||
" makes the vim window split horizontally, with search result displayed in
|
||||
" the new window.
|
||||
"
|
||||
" (Note: earlier versions of vim may not have the :scs command, but it
|
||||
" can be simulated roughly via:
|
||||
" nmap <C-@>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR>
|
||||
|
||||
nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
|
||||
nmap <C-@>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
|
||||
nmap <C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR>
|
||||
|
||||
|
||||
" Hitting CTRL-space *twice* before the search type does a vertical
|
||||
" split instead of a horizontal one (vim 6 and up only)
|
||||
"
|
||||
" (Note: you may wish to put a 'set splitright' in your .vimrc
|
||||
" if you prefer the new window on the right instead of the left
|
||||
|
||||
nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
|
||||
nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
|
||||
nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
|
||||
nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
|
||||
|
||||
|
||||
""""""""""""" key map timeouts
|
||||
"
|
||||
" By default Vim will only wait 1 second for each keystroke in a mapping.
|
||||
" You may find that too short with the above typemaps. If so, you should
|
||||
" either turn off mapping timeouts via 'notimeout'.
|
||||
"
|
||||
"set notimeout
|
||||
"
|
||||
" Or, you can keep timeouts, by uncommenting the timeoutlen line below,
|
||||
" with your own personal favorite value (in milliseconds):
|
||||
"
|
||||
"set timeoutlen=4000
|
||||
"
|
||||
" Either way, since mapping timeout settings by default also set the
|
||||
" timeouts for multicharacter 'keys codes' (like <F1>), you should also
|
||||
" set ttimeout and ttimeoutlen: otherwise, you will experience strange
|
||||
" delays as vim waits for a keystroke after you hit ESC (it will be
|
||||
" waiting to see if the ESC is actually part of a key code like <F1>).
|
||||
"
|
||||
"set ttimeout
|
||||
"
|
||||
" personally, I find a tenth of a second to work well for key code
|
||||
" timeouts. If you experience problems and have a slow terminal or network
|
||||
" connection, set it higher. If you don't set ttimeoutlen, the value for
|
||||
" timeoutlent (default: 1000 = 1 second, which is sluggish) is used.
|
||||
"
|
||||
"set ttimeoutlen=100
|
||||
|
||||
endif
|
||||
|
||||
|
||||
24
dot_vim/plugin/cscopemenu.vim
Normal file
24
dot_vim/plugin/cscopemenu.vim
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
" Add_Cscope_Menu
|
||||
" Adds a cscope menu
|
||||
" All the commands work on the word that is under the cursor
|
||||
function! s:Add_CScope_Menu(menu_clear)
|
||||
if has("gui_running")
|
||||
if (a:menu_clear)
|
||||
|
||||
silent! unmenu &Cscope
|
||||
silent! unmenu! &Cscope
|
||||
amenu <silent> &Cscope.Find\ functions\ calling\ this\ function :cs find c <C-R>=expand("<cword>") <CR><CR>
|
||||
amenu <silent> &Cscope.Find\ functions\ called\ by\ this\ function :cs find d <C-R>=expand("<cword>") <CR><CR>
|
||||
amenu <silent> &Cscope.Find\ this\ egrep\ pattern :cs find e <C-R>=expand("<cword>") <CR><CR>
|
||||
amenu <silent> &Cscope.Find\ this\ file :cs find f <C-R>=expand("<cword>") <CR><CR>
|
||||
amenu <silent> &Cscope.Find\ this\ definition :cs find g <C-R>=expand("<cword>") <CR><CR>
|
||||
amenu <silent> &Cscope.Find\ files\ #including\ this\ file :cs find i <C-R>=expand("<cfile>") <CR><CR>
|
||||
amenu <silent> &Cscope.Find\ this\ Symbol :cs find s <C-R>=expand("<cword>") <CR><CR>
|
||||
amenu <silent> &Cscope.Find\ assignments\ to :cs find t <C-R>=expand("<cword>") <CR><CR>
|
||||
endif
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
|
||||
autocmd BufEnter * call s:Add_CScope_Menu(1)
|
||||
996
dot_vim/plugin/genutils.vim
Executable file
996
dot_vim/plugin/genutils.vim
Executable file
File diff suppressed because it is too large
Load diff
27
dot_vim/plugin/gotags.vim
Normal file
27
dot_vim/plugin/gotags.vim
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
let g:tagbar_type_go = {
|
||||
\ 'ctagstype' : 'go',
|
||||
\ 'kinds' : [
|
||||
\ 'p:package',
|
||||
\ 'i:imports:1',
|
||||
\ 'c:constants',
|
||||
\ 'v:variables',
|
||||
\ 't:types',
|
||||
\ 'n:interfaces',
|
||||
\ 'w:fields',
|
||||
\ 'e:embedded',
|
||||
\ 'm:methods',
|
||||
\ 'r:constructor',
|
||||
\ 'f:functions'
|
||||
\ ],
|
||||
\ 'sro' : '.',
|
||||
\ 'kind2scope' : {
|
||||
\ 't' : 'ctype',
|
||||
\ 'n' : 'ntype'
|
||||
\ },
|
||||
\ 'scope2kind' : {
|
||||
\ 'ctype' : 't',
|
||||
\ 'ntype' : 'n'
|
||||
\ },
|
||||
\ 'ctagsbin' : 'gotags',
|
||||
\ 'ctagsargs' : '-sort -silent'
|
||||
\ }
|
||||
812
dot_vim/plugin/matchit.vim
Executable file
812
dot_vim/plugin/matchit.vim
Executable file
File diff suppressed because it is too large
Load diff
257
dot_vim/plugin/vcsbzr.vim
Normal file
257
dot_vim/plugin/vcsbzr.vim
Normal file
|
|
@ -0,0 +1,257 @@
|
|||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" BZR extension for VCSCommand.
|
||||
"
|
||||
" Version: VCS development
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) 2009 Bob Hiestand
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to
|
||||
" deal in the Software without restriction, including without limitation the
|
||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
" sell copies of the Software, and to permit persons to whom the Software is
|
||||
" furnished to do so, subject to the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included in
|
||||
" all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
" IN THE SOFTWARE.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandBZRExec
|
||||
" This variable specifies the BZR executable. If not set, it defaults to
|
||||
" 'bzr' executed from the user's executable path.
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandBZRExec', 'bzr'))
|
||||
" BZR is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:bzrFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke bzr suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return shellescape(VCSCommandGetOption('VCSCommandBZRExec', 'bzr'))
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the BZR executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'BZR'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'BZR VCSCommand plugin called on non-BZR item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:bzrFunctions.Identify(buffer) {{{2
|
||||
function! s:bzrFunctions.Identify(buffer)
|
||||
let fileName = resolve(bufname(a:buffer))
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' info -- "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Add() {{{2
|
||||
function! s:bzrFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Annotate(argList) {{{2
|
||||
function! s:bzrFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'BZRannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = ''
|
||||
let options = ''
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = join(a:argList, ' ')
|
||||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
|
||||
if resultBuffer > 0
|
||||
normal 1G2dd
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Commit(argList) {{{2
|
||||
function! s:bzrFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Delete() {{{2
|
||||
function! s:bzrFunctions.Delete(argList)
|
||||
return s:DoCommand(join(['rm'] + a:argList, ' '), 'rm', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Diff(argList) {{{2
|
||||
function! s:bzrFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, '..')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin.
|
||||
" Returns: List of results: [revision, repository]
|
||||
|
||||
function! s:bzrFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = resolve(bufname(originalBuffer))
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -S -- "' . fileName . '"')
|
||||
let revision = s:VCSCommandUtility.system(s:Executable() . ' revno -- "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
||||
" File not under BZR control.
|
||||
if statusText =~ '^?'
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let [flags, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)')[1:2]
|
||||
if revision == ''
|
||||
" Error
|
||||
return ['Unknown']
|
||||
elseif flags =~ '^A'
|
||||
return ['New', 'New']
|
||||
else
|
||||
return [revision, repository]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Info(argList) {{{2
|
||||
function! s:bzrFunctions.Info(argList)
|
||||
return s:DoCommand(join(['version-info'] + a:argList, ' '), 'version-info', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Lock(argList) {{{2
|
||||
function! s:bzrFunctions.Lock(argList)
|
||||
echomsg 'bzr lock is not necessary'
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Log() {{{2
|
||||
function! s:bzrFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Revert(argList) {{{2
|
||||
function! s:bzrFunctions.Revert(argList)
|
||||
return s:DoCommand('revert', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Review(argList) {{{2
|
||||
function! s:bzrFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Status(argList) {{{2
|
||||
function! s:bzrFunctions.Status(argList)
|
||||
let options = ['-S']
|
||||
if len(a:argList) == 0
|
||||
let options = a:argList
|
||||
endif
|
||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Unlock(argList) {{{2
|
||||
function! s:bzrFunctions.Unlock(argList)
|
||||
echomsg 'bzr unlock is not necessary'
|
||||
endfunction
|
||||
" Function: s:bzrFunctions.Update(argList) {{{2
|
||||
function! s:bzrFunctions.Update(argList)
|
||||
return s:DoCommand('update', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:bzrFunctions.AnnotateSplitRegex = '^[^|]\+ | '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('BZR', expand('<sfile>'), s:bzrFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
1402
dot_vim/plugin/vcscommand.vim
Normal file
1402
dot_vim/plugin/vcscommand.vim
Normal file
File diff suppressed because it is too large
Load diff
445
dot_vim/plugin/vcscvs.vim
Normal file
445
dot_vim/plugin/vcscvs.vim
Normal file
|
|
@ -0,0 +1,445 @@
|
|||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" CVS extension for VCSCommand.
|
||||
"
|
||||
" Version: VCS development
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) 2007 Bob Hiestand
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to
|
||||
" deal in the Software without restriction, including without limitation the
|
||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
" sell copies of the Software, and to permit persons to whom the Software is
|
||||
" furnished to do so, subject to the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included in
|
||||
" all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
" IN THE SOFTWARE.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Command documentation {{{2
|
||||
"
|
||||
" The following commands only apply to files under CVS source control.
|
||||
"
|
||||
" CVSEdit Performs "cvs edit" on the current file.
|
||||
"
|
||||
" CVSEditors Performs "cvs editors" on the current file.
|
||||
"
|
||||
" CVSUnedit Performs "cvs unedit" on the current file.
|
||||
"
|
||||
" CVSWatch Takes an argument which must be one of [on|off|add|remove].
|
||||
" Performs "cvs watch" with the given argument on the current
|
||||
" file.
|
||||
"
|
||||
" CVSWatchers Performs "cvs watchers" on the current file.
|
||||
"
|
||||
" CVSWatchAdd Alias for "CVSWatch add"
|
||||
"
|
||||
" CVSWatchOn Alias for "CVSWatch on"
|
||||
"
|
||||
" CVSWatchOff Alias for "CVSWatch off"
|
||||
"
|
||||
" CVSWatchRemove Alias for "CVSWatch remove"
|
||||
"
|
||||
" Mapping documentation: {{{2
|
||||
"
|
||||
" By default, a mapping is defined for each command. User-provided mappings
|
||||
" can be used instead by mapping to <Plug>CommandName, for instance:
|
||||
"
|
||||
" nnoremap ,ce <Plug>CVSEdit
|
||||
"
|
||||
" The default mappings are as follow:
|
||||
"
|
||||
" <Leader>ce CVSEdit
|
||||
" <Leader>cE CVSEditors
|
||||
" <Leader>ct CVSUnedit
|
||||
" <Leader>cwv CVSWatchers
|
||||
" <Leader>cwa CVSWatchAdd
|
||||
" <Leader>cwn CVSWatchOn
|
||||
" <Leader>cwf CVSWatchOff
|
||||
" <Leader>cwr CVSWatchRemove
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandCVSExec
|
||||
" This variable specifies the CVS executable. If not set, it defaults to
|
||||
" 'cvs' executed from the user's executable path.
|
||||
"
|
||||
" VCSCommandCVSDiffOpt
|
||||
" This variable, if set, determines the options passed to the cvs diff
|
||||
" command. If not set, it defaults to 'u'.
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandCVSExec', 'cvs'))
|
||||
" CVS is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:cvsFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke cvs suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return shellescape(VCSCommandGetOption('VCSCommandCVSExec', 'cvs'))
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the CVS executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'CVS'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
let ret = VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
|
||||
if ret > 0
|
||||
if getline(line('$')) =~ '^cvs \w\+: closing down connection'
|
||||
$d
|
||||
1
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
return ret
|
||||
else
|
||||
throw 'CVS VCSCommand plugin called on non-CVS item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:GetRevision() {{{2
|
||||
" Function for retrieving the current buffer's revision number.
|
||||
" Returns: Revision number or an empty string if an error occurs.
|
||||
|
||||
function! s:GetRevision()
|
||||
if !exists('b:VCSCommandBufferInfo')
|
||||
let b:VCSCommandBufferInfo = s:cvsFunctions.GetBufferInfo()
|
||||
endif
|
||||
|
||||
if len(b:VCSCommandBufferInfo) > 0
|
||||
return b:VCSCommandBufferInfo[0]
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:cvsFunctions.Identify(buffer) {{{2
|
||||
function! s:cvsFunctions.Identify(buffer)
|
||||
let fileName = resolve(bufname(a:buffer))
|
||||
if isdirectory(fileName)
|
||||
let directoryName = fileName
|
||||
else
|
||||
let directoryName = fnamemodify(fileName, ':h')
|
||||
endif
|
||||
if strlen(directoryName) > 0
|
||||
let CVSRoot = directoryName . '/CVS/Root'
|
||||
else
|
||||
let CVSRoot = 'CVS/Root'
|
||||
endif
|
||||
if filereadable(CVSRoot)
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Add(argList) {{{2
|
||||
function! s:cvsFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Annotate(argList) {{{2
|
||||
function! s:cvsFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'CVSannotate'
|
||||
" This is a CVSAnnotate buffer. Perform annotation of the version
|
||||
" indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^[0-9.]+')
|
||||
|
||||
if VCSCommandGetOption('VCSCommandCVSAnnotateParent', 0) != 0
|
||||
if caption != '1.1'
|
||||
let revmaj = matchstr(caption,'\v[0-9.]+\ze\.[0-9]+')
|
||||
let revmin = matchstr(caption,'\v[0-9.]+\.\zs[0-9]+') - 1
|
||||
if revmin == 0
|
||||
" Jump to ancestor branch
|
||||
let caption = matchstr(revmaj,'\v[0-9.]+\ze\.[0-9]+')
|
||||
else
|
||||
let caption = revmaj . "." . revmin
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
let options = ['-r' . caption]
|
||||
else
|
||||
" CVS defaults to pulling HEAD, regardless of current branch.
|
||||
" Therefore, always pass desired revision.
|
||||
let caption = ''
|
||||
let options = ['-r' . s:GetRevision()]
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ['-r' . caption]
|
||||
else
|
||||
let caption = join(a:argList)
|
||||
let options = a:argList
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['-q', 'annotate'] + options), 'annotate', caption, {})
|
||||
if resultBuffer > 0
|
||||
" Remove header lines from standard error
|
||||
silent v/^\d\+\%(\.\d\+\)\+/d
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Commit(argList) {{{2
|
||||
function! s:cvsFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Delete() {{{2
|
||||
" By default, use the -f option to remove the file first. If options are
|
||||
" passed in, use those instead.
|
||||
function! s:cvsFunctions.Delete(argList)
|
||||
let options = ['-f']
|
||||
let caption = ''
|
||||
if len(a:argList) > 0
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
return s:DoCommand(join(['remove'] + options, ' '), 'delete', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Diff(argList) {{{2
|
||||
function! s:cvsFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, ' -r')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
let cvsDiffOpt = VCSCommandGetOption('VCSCommandCVSDiffOpt', 'u')
|
||||
if cvsDiffOpt == ''
|
||||
let diffOptions = []
|
||||
else
|
||||
let diffOptions = ['-' . cvsDiffOpt]
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff'] + diffOptions + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin. This CVS extension adds branch name to the return
|
||||
" list as well.
|
||||
" Returns: List of results: [revision, repository, branch]
|
||||
|
||||
function! s:cvsFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = bufname(originalBuffer)
|
||||
if isdirectory(fileName)
|
||||
let tag = ''
|
||||
if filereadable(fileName . '/CVS/Tag')
|
||||
let tagFile = readfile(fileName . '/CVS/Tag')
|
||||
if len(tagFile) == 1
|
||||
let tag = substitute(tagFile[0], '^T', '', '')
|
||||
endif
|
||||
endif
|
||||
return [tag]
|
||||
endif
|
||||
let realFileName = fnamemodify(resolve(fileName), ':t')
|
||||
if !filereadable(fileName)
|
||||
return ['Unknown']
|
||||
endif
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(fileName)
|
||||
try
|
||||
let statusText=s:VCSCommandUtility.system(s:Executable() . ' status -- "' . realFileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
let revision=substitute(statusText, '^\_.*Working revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\)\_.*$', '\1', '')
|
||||
|
||||
" We can still be in a CVS-controlled directory without this being a CVS
|
||||
" file
|
||||
if match(revision, '^New file!$') >= 0
|
||||
let revision='New'
|
||||
elseif match(revision, '^\d\+\.\d\+\%(\.\d\+\.\d\+\)*$') <0
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let branch=substitute(statusText, '^\_.*Sticky Tag:\s\+\(\d\+\%(\.\d\+\)\+\|\a[A-Za-z0-9-_]*\|(none)\).*$', '\1', '')
|
||||
let repository=substitute(statusText, '^\_.*Repository revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\|No revision control file\)\_.*$', '\1', '')
|
||||
let repository=substitute(repository, '^New file!\|No revision control file$', 'New', '')
|
||||
return [revision, repository, branch]
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Log() {{{2
|
||||
function! s:cvsFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['log'] + options), 'log', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Revert(argList) {{{2
|
||||
function! s:cvsFunctions.Revert(argList)
|
||||
return s:DoCommand('update -C', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Review(argList) {{{2
|
||||
function! s:cvsFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
return s:DoCommand('-q update -p' . versionOption, 'review', versiontag, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Status(argList) {{{2
|
||||
function! s:cvsFunctions.Status(argList)
|
||||
return s:DoCommand(join(['status'] + a:argList, ' '), 'status', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Update(argList) {{{2
|
||||
function! s:cvsFunctions.Update(argList)
|
||||
return s:DoCommand('update', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Section: CVS-specific functions {{{1
|
||||
|
||||
" Function: s:CVSEdit() {{{2
|
||||
function! s:CVSEdit()
|
||||
return s:DoCommand('edit', 'cvsedit', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:CVSEditors() {{{2
|
||||
function! s:CVSEditors()
|
||||
return s:DoCommand('editors', 'cvseditors', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:CVSUnedit() {{{2
|
||||
function! s:CVSUnedit()
|
||||
return s:DoCommand('unedit', 'cvsunedit', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:CVSWatch(onoff) {{{2
|
||||
function! s:CVSWatch(onoff)
|
||||
if a:onoff !~ '^\c\%(on\|off\|add\|remove\)$'
|
||||
echoerr 'Argument to CVSWatch must be one of [on|off|add|remove]'
|
||||
return -1
|
||||
end
|
||||
return s:DoCommand('watch ' . tolower(a:onoff), 'cvswatch', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:CVSWatchers() {{{2
|
||||
function! s:CVSWatchers()
|
||||
return s:DoCommand('watchers', 'cvswatchers', '', {})
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:cvsFunctions.AnnotateSplitRegex = '): '
|
||||
|
||||
" Section: Command definitions {{{1
|
||||
" Section: Primary commands {{{2
|
||||
com! CVSEdit call s:CVSEdit()
|
||||
com! CVSEditors call s:CVSEditors()
|
||||
com! CVSUnedit call s:CVSUnedit()
|
||||
com! -nargs=1 CVSWatch call s:CVSWatch(<f-args>)
|
||||
com! CVSWatchAdd call s:CVSWatch('add')
|
||||
com! CVSWatchOn call s:CVSWatch('on')
|
||||
com! CVSWatchOff call s:CVSWatch('off')
|
||||
com! CVSWatchRemove call s:CVSWatch('remove')
|
||||
com! CVSWatchers call s:CVSWatchers()
|
||||
|
||||
" Section: Plugin command mappings {{{1
|
||||
|
||||
let s:cvsExtensionMappings = {}
|
||||
let mappingInfo = [
|
||||
\['CVSEdit', 'CVSEdit', 'e'],
|
||||
\['CVSEditors', 'CVSEditors', 'E'],
|
||||
\['CVSUnedit', 'CVSUnedit', 't'],
|
||||
\['CVSWatchers', 'CVSWatchers', 'wv'],
|
||||
\['CVSWatchAdd', 'CVSWatch add', 'wa'],
|
||||
\['CVSWatchOff', 'CVSWatch off', 'wf'],
|
||||
\['CVSWatchOn', 'CVSWatch on', 'wn'],
|
||||
\['CVSWatchRemove', 'CVSWatch remove', 'wr']
|
||||
\]
|
||||
|
||||
for [pluginName, commandText, shortCut] in mappingInfo
|
||||
execute 'nnoremap <silent> <Plug>' . pluginName . ' :' . commandText . '<CR>'
|
||||
if !hasmapto('<Plug>' . pluginName)
|
||||
let s:cvsExtensionMappings[shortCut] = commandText
|
||||
endif
|
||||
endfor
|
||||
|
||||
" Section: Menu items {{{1
|
||||
amenu <silent> &Plugin.VCS.CVS.&Edit <Plug>CVSEdit
|
||||
amenu <silent> &Plugin.VCS.CVS.Ed&itors <Plug>CVSEditors
|
||||
amenu <silent> &Plugin.VCS.CVS.Unedi&t <Plug>CVSUnedit
|
||||
amenu <silent> &Plugin.VCS.CVS.&Watchers <Plug>CVSWatchers
|
||||
amenu <silent> &Plugin.VCS.CVS.WatchAdd <Plug>CVSWatchAdd
|
||||
amenu <silent> &Plugin.VCS.CVS.WatchOn <Plug>CVSWatchOn
|
||||
amenu <silent> &Plugin.VCS.CVS.WatchOff <Plug>CVSWatchOff
|
||||
amenu <silent> &Plugin.VCS.CVS.WatchRemove <Plug>CVSWatchRemove
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('CVS', expand('<sfile>'), s:cvsFunctions, s:cvsExtensionMappings)
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
248
dot_vim/plugin/vcsgit.vim
Normal file
248
dot_vim/plugin/vcsgit.vim
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" git extension for VCSCommand.
|
||||
"
|
||||
" Version: VCS development
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) 2008 Bob Hiestand
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to
|
||||
" deal in the Software without restriction, including without limitation the
|
||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
" sell copies of the Software, and to permit persons to whom the Software is
|
||||
" furnished to do so, subject to the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included in
|
||||
" all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
" IN THE SOFTWARE.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandGitExec
|
||||
" This variable specifies the git executable. If not set, it defaults to
|
||||
" 'git' executed from the user's executable path.
|
||||
"
|
||||
" VCSCommandGitDiffOpt
|
||||
" This variable, if set, determines the default options passed to the
|
||||
" VCSDiff command. If any options (starting with '-') are passed to the
|
||||
" command, this variable is not used.
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandGitExec', 'git'))
|
||||
" git is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:gitFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke git suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return shellescape(VCSCommandGetOption('VCSCommandGitExec', 'git'))
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the git executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'git'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'git VCSCommand plugin called on non-git item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:gitFunctions.Identify(buffer) {{{2
|
||||
" This function only returns an inexact match due to the detection method used
|
||||
" by git, which simply traverses the directory structure upward.
|
||||
function! s:gitFunctions.Identify(buffer)
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
|
||||
try
|
||||
call s:VCSCommandUtility.system(s:Executable() . ' rev-parse --is-inside-work-tree')
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return g:VCSCOMMAND_IDENTIFY_INEXACT
|
||||
endif
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Add(argList) {{{2
|
||||
function! s:gitFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + ['-v'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Annotate(argList) {{{2
|
||||
function! s:gitFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'gitannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let options = matchstr(getline('.'),'^\x\+')
|
||||
else
|
||||
let options = ''
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let options = a:argList[0]
|
||||
else
|
||||
let options = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
return s:DoCommand('blame ' . options, 'annotate', options, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Commit(argList) {{{2
|
||||
function! s:gitFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Delete() {{{2
|
||||
" All options are passed through.
|
||||
function! s:gitFunctions.Delete(argList)
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
return s:DoCommand(join(['rm'] + options, ' '), 'delete', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Diff(argList) {{{2
|
||||
" Pass-through call to git-diff. If no options (starting with '-') are found,
|
||||
" then the options in the 'VCSCommandGitDiffOpt' variable are added.
|
||||
function! s:gitFunctions.Diff(argList)
|
||||
let gitDiffOpt = VCSCommandGetOption('VCSCommandGitDiffOpt', '')
|
||||
if gitDiffOpt == ''
|
||||
let diffOptions = []
|
||||
else
|
||||
let diffOptions = [gitDiffOpt]
|
||||
for arg in a:argList
|
||||
if arg =~ '^-'
|
||||
let diffOptions = []
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff'] + diffOptions + a:argList), 'diff', join(a:argList), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin. This CVS extension adds branch name to the return
|
||||
" list as well.
|
||||
" Returns: List of results: [revision, repository, branch]
|
||||
|
||||
function! s:gitFunctions.GetBufferInfo()
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname('%')))
|
||||
try
|
||||
let branch = substitute(s:VCSCommandUtility.system(s:Executable() . ' symbolic-ref -q HEAD'), '\n$', '', '')
|
||||
if v:shell_error
|
||||
let branch = 'DETACHED'
|
||||
else
|
||||
let branch = substitute(branch, '^refs/heads/', '', '')
|
||||
endif
|
||||
|
||||
let info = [branch]
|
||||
|
||||
for method in split(VCSCommandGetOption('VCSCommandGitDescribeArgList', (',tags,all,always')), ',', 1)
|
||||
if method != ''
|
||||
let method = ' --' . method
|
||||
endif
|
||||
let tag = substitute(s:VCSCommandUtility.system(s:Executable() . ' describe' . method), '\n$', '', '')
|
||||
if !v:shell_error
|
||||
call add(info, tag)
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
return info
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Log() {{{2
|
||||
function! s:gitFunctions.Log(argList)
|
||||
return s:DoCommand(join(['log'] + a:argList), 'log', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Revert(argList) {{{2
|
||||
function! s:gitFunctions.Revert(argList)
|
||||
return s:DoCommand('checkout', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Review(argList) {{{2
|
||||
function! s:gitFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let revision = 'HEAD'
|
||||
else
|
||||
let revision = a:argList[0]
|
||||
endif
|
||||
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(VCSCommandGetOriginalBuffer('%'))))
|
||||
try
|
||||
let prefix = s:VCSCommandUtility.system(s:Executable() . ' rev-parse --show-prefix')
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
|
||||
let prefix = substitute(prefix, '\n$', '', '')
|
||||
let blob = '"' . revision . ':' . prefix . '<VCSCOMMANDFILE>"'
|
||||
return s:DoCommand('show ' . blob, 'review', revision, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Status(argList) {{{2
|
||||
function! s:gitFunctions.Status(argList)
|
||||
return s:DoCommand(join(['status'] + a:argList), 'status', join(a:argList), {'allowNonZeroExit': 1})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Update(argList) {{{2
|
||||
function! s:gitFunctions.Update(argList)
|
||||
throw "This command is not implemented for git because file-by-file update doesn't make much sense in that context. If you have an idea for what it should do, please let me know."
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:gitFunctions.AnnotateSplitRegex = ') '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('git', expand('<sfile>'), s:gitFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
273
dot_vim/plugin/vcshg.vim
Executable file
273
dot_vim/plugin/vcshg.vim
Executable file
|
|
@ -0,0 +1,273 @@
|
|||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" Mercurial extension for VCSCommand.
|
||||
"
|
||||
" Version: VCS development
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) 2009 Bob Hiestand
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to
|
||||
" deal in the Software without restriction, including without limitation the
|
||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
" sell copies of the Software, and to permit persons to whom the Software is
|
||||
" furnished to do so, subject to the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included in
|
||||
" all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
" IN THE SOFTWARE.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandHGExec
|
||||
" This variable specifies the mercurial executable. If not set, it defaults
|
||||
" to 'hg' executed from the user's executable path.
|
||||
"
|
||||
" VCSCommandHGDiffExt
|
||||
" This variable, if set, sets the external diff program used by Subversion.
|
||||
"
|
||||
" VCSCommandHGDiffOpt
|
||||
" This variable, if set, determines the options passed to the hg diff
|
||||
" command (such as 'u', 'w', or 'b').
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandHGExec', 'hg'))
|
||||
" HG is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:hgFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke hg suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return shellescape(VCSCommandGetOption('VCSCommandHGExec', 'hg'))
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the HG executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'HG'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'HG VCSCommand plugin called on non-HG item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:hgFunctions.Identify(buffer) {{{2
|
||||
function! s:hgFunctions.Identify(buffer)
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
|
||||
try
|
||||
call s:VCSCommandUtility.system(s:Executable() . ' root')
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return g:VCSCOMMAND_IDENTIFY_INEXACT
|
||||
endif
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Add() {{{2
|
||||
function! s:hgFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Annotate(argList) {{{2
|
||||
function! s:hgFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'HGannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = ''
|
||||
let options = ' -un'
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ' -un -r' . caption
|
||||
else
|
||||
let caption = join(a:argList, ' ')
|
||||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
return s:DoCommand('blame' . options, 'annotate', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Commit(argList) {{{2
|
||||
function! s:hgFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit -l "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Delete() {{{2
|
||||
function! s:hgFunctions.Delete(argList)
|
||||
return s:DoCommand(join(['remove'] + a:argList, ' '), 'remove', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Diff(argList) {{{2
|
||||
function! s:hgFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, ':')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
let hgDiffExt = VCSCommandGetOption('VCSCommandHGDiffExt', '')
|
||||
if hgDiffExt == ''
|
||||
let diffExt = []
|
||||
else
|
||||
let diffExt = ['--diff-cmd ' . hgDiffExt]
|
||||
endif
|
||||
|
||||
let hgDiffOpt = VCSCommandGetOption('VCSCommandHGDiffOpt', '')
|
||||
if hgDiffOpt == ''
|
||||
let diffOptions = []
|
||||
else
|
||||
let diffOptions = ['-x -' . hgDiffOpt]
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Info(argList) {{{2
|
||||
function! s:hgFunctions.Info(argList)
|
||||
return s:DoCommand(join(['log --limit 1'] + a:argList, ' '), 'log', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin.
|
||||
" Returns: List of results: [revision, repository, branch]
|
||||
|
||||
function! s:hgFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = bufname(originalBuffer)
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -- "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
||||
" File not under HG control.
|
||||
if statusText =~ '^?'
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let parentsText = s:VCSCommandUtility.system(s:Executable() . ' parents -- "' . fileName . '"')
|
||||
let revision = matchlist(parentsText, '^changeset:\s\+\(\S\+\)\n')[1]
|
||||
|
||||
let logText = s:VCSCommandUtility.system(s:Executable() . ' log -- "' . fileName . '"')
|
||||
let repository = matchlist(logText, '^changeset:\s\+\(\S\+\)\n')[1]
|
||||
|
||||
if revision == ''
|
||||
" Error
|
||||
return ['Unknown']
|
||||
elseif statusText =~ '^A'
|
||||
return ['New', 'New']
|
||||
else
|
||||
return [revision, repository]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Log(argList) {{{2
|
||||
function! s:hgFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Revert(argList) {{{2
|
||||
function! s:hgFunctions.Revert(argList)
|
||||
return s:DoCommand('revert', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Review(argList) {{{2
|
||||
function! s:hgFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Status(argList) {{{2
|
||||
function! s:hgFunctions.Status(argList)
|
||||
let options = ['-u', '-v']
|
||||
if len(a:argList) == 0
|
||||
let options = a:argList
|
||||
endif
|
||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Update(argList) {{{2
|
||||
function! s:hgFunctions.Update(argList)
|
||||
return s:DoCommand('update', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:hgFunctions.AnnotateSplitRegex = '\d\+: '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('HG', expand('<sfile>'), s:hgFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
258
dot_vim/plugin/vcssvk.vim
Normal file
258
dot_vim/plugin/vcssvk.vim
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" SVK extension for VCSCommand.
|
||||
"
|
||||
" Version: VCS development
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) 2007 Bob Hiestand
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to
|
||||
" deal in the Software without restriction, including without limitation the
|
||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
" sell copies of the Software, and to permit persons to whom the Software is
|
||||
" furnished to do so, subject to the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included in
|
||||
" all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
" IN THE SOFTWARE.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandSVKExec
|
||||
" This variable specifies the SVK executable. If not set, it defaults to
|
||||
" 'svk' executed from the user's executable path.
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandSVKExec', 'svk'))
|
||||
" SVK is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:svkFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke SVK suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return shellescape(VCSCommandGetOption('VCSCommandSVKExec', 'svk'))
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the SVK executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'SVK'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'SVK VCSCommand plugin called on non-SVK item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:svkFunctions.Identify(buffer) {{{2
|
||||
function! s:svkFunctions.Identify(buffer)
|
||||
let fileName = resolve(bufname(a:buffer))
|
||||
if isdirectory(fileName)
|
||||
let directoryName = fileName
|
||||
else
|
||||
let directoryName = fnamemodify(fileName, ':p:h')
|
||||
endif
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' info -- "' . directoryName . '"', "no")
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Add() {{{2
|
||||
function! s:svkFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Annotate(argList) {{{2
|
||||
function! s:svkFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'SVKannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = ''
|
||||
let options = ''
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = join(a:argList, ' ')
|
||||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
|
||||
if resultBuffer > 0
|
||||
normal 1G2dd
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Commit(argList) {{{2
|
||||
function! s:svkFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Delete() {{{2
|
||||
function! s:svkFunctions.Delete(argList)
|
||||
return s:DoCommand(join(['delete'] + a:argList, ' '), 'delete', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Diff(argList) {{{2
|
||||
function! s:svkFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, ':')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin.
|
||||
" Returns: List of results: [revision, repository]
|
||||
|
||||
function! s:svkFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = resolve(bufname(originalBuffer))
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -v -- "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
||||
" File not under SVK control.
|
||||
if statusText =~ '^?'
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let [flags, revision, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3]
|
||||
if revision == ''
|
||||
" Error
|
||||
return ['Unknown']
|
||||
elseif flags =~ '^A'
|
||||
return ['New', 'New']
|
||||
else
|
||||
return [revision, repository]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Info(argList) {{{2
|
||||
function! s:svkFunctions.Info(argList)
|
||||
return s:DoCommand(join(['info'] + a:argList, ' '), 'info', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Lock(argList) {{{2
|
||||
function! s:svkFunctions.Lock(argList)
|
||||
return s:DoCommand(join(['lock'] + a:argList, ' '), 'lock', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Log() {{{2
|
||||
function! s:svkFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Revert(argList) {{{2
|
||||
function! s:svkFunctions.Revert(argList)
|
||||
return s:DoCommand('revert', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Review(argList) {{{2
|
||||
function! s:svkFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Status(argList) {{{2
|
||||
function! s:svkFunctions.Status(argList)
|
||||
let options = ['-v']
|
||||
if len(a:argList) == 0
|
||||
let options = a:argList
|
||||
endif
|
||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Unlock(argList) {{{2
|
||||
function! s:svkFunctions.Unlock(argList)
|
||||
return s:DoCommand(join(['unlock'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
" Function: s:svkFunctions.Update(argList) {{{2
|
||||
function! s:svkFunctions.Update(argList)
|
||||
return s:DoCommand('update', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('SVK', expand('<sfile>'), s:svkFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
283
dot_vim/plugin/vcssvn.vim
Normal file
283
dot_vim/plugin/vcssvn.vim
Normal file
|
|
@ -0,0 +1,283 @@
|
|||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" SVN extension for VCSCommand.
|
||||
"
|
||||
" Version: VCS development
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) 2007 Bob Hiestand
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to
|
||||
" deal in the Software without restriction, including without limitation the
|
||||
" rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
" sell copies of the Software, and to permit persons to whom the Software is
|
||||
" furnished to do so, subject to the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included in
|
||||
" all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
" FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
" IN THE SOFTWARE.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandSVNExec
|
||||
" This variable specifies the SVN executable. If not set, it defaults to
|
||||
" 'svn' executed from the user's executable path.
|
||||
"
|
||||
" VCSCommandSVNDiffExt
|
||||
" This variable, if set, sets the external diff program used by Subversion.
|
||||
"
|
||||
" VCSCommandSVNDiffOpt
|
||||
" This variable, if set, determines the options passed to the svn diff
|
||||
" command (such as 'u', 'w', or 'b').
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandSVNExec', 'svn'))
|
||||
" SVN is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:svnFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke git suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return shellescape(VCSCommandGetOption('VCSCommandSVNExec', 'svn'))
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the SVN executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'SVN'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'SVN VCSCommand plugin called on non-SVN item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:svnFunctions.Identify(buffer) {{{2
|
||||
function! s:svnFunctions.Identify(buffer)
|
||||
let fileName = resolve(bufname(a:buffer))
|
||||
if isdirectory(fileName)
|
||||
let directoryName = fileName
|
||||
else
|
||||
let directoryName = fnamemodify(fileName, ':h')
|
||||
endif
|
||||
if strlen(directoryName) > 0
|
||||
let svnDir = directoryName . '/.svn'
|
||||
else
|
||||
let svnDir = '.svn'
|
||||
endif
|
||||
if isdirectory(svnDir)
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Add() {{{2
|
||||
function! s:svnFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Annotate(argList) {{{2
|
||||
function! s:svnFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'SVNannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = ''
|
||||
let options = ''
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = join(a:argList, ' ')
|
||||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
return s:DoCommand('blame --non-interactive' . options, 'annotate', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Commit(argList) {{{2
|
||||
function! s:svnFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit --non-interactive -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Delete() {{{2
|
||||
function! s:svnFunctions.Delete(argList)
|
||||
return s:DoCommand(join(['delete --non-interactive'] + a:argList, ' '), 'delete', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Diff(argList) {{{2
|
||||
function! s:svnFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, ':')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
let svnDiffExt = VCSCommandGetOption('VCSCommandSVNDiffExt', '')
|
||||
if svnDiffExt == ''
|
||||
let diffExt = []
|
||||
else
|
||||
let diffExt = ['--diff-cmd ' . svnDiffExt]
|
||||
endif
|
||||
|
||||
let svnDiffOpt = VCSCommandGetOption('VCSCommandSVNDiffOpt', '')
|
||||
if svnDiffOpt == ''
|
||||
let diffOptions = []
|
||||
else
|
||||
let diffOptions = ['-x -' . svnDiffOpt]
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff --non-interactive'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin.
|
||||
" Returns: List of results: [revision, repository, branch]
|
||||
|
||||
function! s:svnFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = bufname(originalBuffer)
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status --non-interactive -vu -- "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
||||
" File not under SVN control.
|
||||
if statusText =~ '^?'
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let [flags, revision, repository] = matchlist(statusText, '^\(.\{8}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3]
|
||||
if revision == ''
|
||||
" Error
|
||||
return ['Unknown']
|
||||
elseif flags =~ '^A'
|
||||
return ['New', 'New']
|
||||
else
|
||||
return [revision, repository]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Info(argList) {{{2
|
||||
function! s:svnFunctions.Info(argList)
|
||||
return s:DoCommand(join(['info --non-interactive'] + a:argList, ' '), 'info', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Lock(argList) {{{2
|
||||
function! s:svnFunctions.Lock(argList)
|
||||
return s:DoCommand(join(['lock --non-interactive'] + a:argList, ' '), 'lock', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Log(argList) {{{2
|
||||
function! s:svnFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['log --non-interactive', '-v'] + options), 'log', caption, {})
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Revert(argList) {{{2
|
||||
function! s:svnFunctions.Revert(argList)
|
||||
return s:DoCommand('revert', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Review(argList) {{{2
|
||||
function! s:svnFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
return s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Status(argList) {{{2
|
||||
function! s:svnFunctions.Status(argList)
|
||||
let options = ['-u', '-v']
|
||||
if len(a:argList) == 0
|
||||
let options = a:argList
|
||||
endif
|
||||
return s:DoCommand(join(['status --non-interactive'] + options, ' '), 'status', join(options, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Unlock(argList) {{{2
|
||||
function! s:svnFunctions.Unlock(argList)
|
||||
return s:DoCommand(join(['unlock --non-interactive'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Update(argList) {{{2
|
||||
function! s:svnFunctions.Update(argList)
|
||||
return s:DoCommand('update --non-interactive', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:svnFunctions.AnnotateSplitRegex = '\s\+\S\+\s\+\S\+ '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('SVN', expand('<sfile>'), s:svnFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
24
dot_vim/plugin/vim-scmdiff/NEWS
Normal file
24
dot_vim/plugin/vim-scmdiff/NEWS
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
2008-09-20
|
||||
* Changed the default diff key from C-d to <Leader>d (default would be \d)
|
||||
|
||||
2008-09-03
|
||||
* Add Enabled/Disabled messages when scmdiff is toggled
|
||||
* Fix highlighting on error messages so subsequent messages aren't highlighted
|
||||
|
||||
2008-08-25
|
||||
* Move Highlight colors out of code so they can be customized by user in .vimrc
|
||||
|
||||
2008-08-18
|
||||
* Initial support for mercurial auto-detection
|
||||
|
||||
2008-08-17
|
||||
* fix bug: Look for SCM directories based on path of file in current buffer, not on getcwd()
|
||||
|
||||
2008-08-15
|
||||
* Add auto-detection of svn, git, and cvs SCMs
|
||||
|
||||
2008-08-10
|
||||
|
||||
* Make C-d a toggle to turn the diff on/off
|
||||
* Avoid deleting unrelated buffers when turning diff off
|
||||
* Autorefresh now works properly
|
||||
22
dot_vim/plugin/vim-scmdiff/README
Normal file
22
dot_vim/plugin/vim-scmdiff/README
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
vim-scmdiff: A Vim script to show the differences from a base version in SCM.
|
||||
|
||||
Supported SCMs:
|
||||
* CVS
|
||||
* SVN
|
||||
* GIT
|
||||
* Mercurial
|
||||
* Bitkeeper
|
||||
|
||||
Installation:
|
||||
copy the scmdiff.vim script to your vim plugin path ie: "~/.vim/plugins". (system paths may vary)
|
||||
|
||||
Default commands:
|
||||
\d Toggle diff view on/off
|
||||
:D rev Difference between current and rev
|
||||
|
||||
This script is an evolution from the scripts posted at the following places:
|
||||
http://tekrat.com/2008/02/21/vim-diff/
|
||||
http://www.vim.org/scripts/script.php?script_id=2201
|
||||
http://playground.audioscrobbler.com/jonty/scmdiff.vim
|
||||
|
||||
11
dot_vim/plugin/vim-scmdiff/TODO
Normal file
11
dot_vim/plugin/vim-scmdiff/TODO
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Bugs
|
||||
|
||||
* After exiting (:q) a buffer that has diff enabled, subsequent diffs appear to fail.
|
||||
* Should restore options like 'wrap' to their original state when turning diff off
|
||||
* winsaveview() and winrestview() require Vim 7.x. Autodetect and degrade gracefully.
|
||||
|
||||
Features
|
||||
|
||||
* Option to show side-by-side diff (ie. don't hide original buffer)
|
||||
* Make it easier to customize colors and commands
|
||||
* Add a refresh or enable an auto-update feature so diff highlighting changes as changes are made.
|
||||
160
dot_vim/plugin/vim-scmdiff/scmdiff.vim
Normal file
160
dot_vim/plugin/vim-scmdiff/scmdiff.vim
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
" Vim script to show file differences from a base version in SCM.
|
||||
" Home: http://github.com/ghewgill/vim-scmdiff
|
||||
|
||||
" Default commands:
|
||||
" \d Toggle diff view on/off
|
||||
" :D rev Difference between current and rev
|
||||
"
|
||||
" You can change the highlighting by adding the following to your
|
||||
" .vimrc file and customizing as necessary. (or just uncomment them here):
|
||||
" highlight DiffAdd ctermbg=DarkBlue ctermfg=white cterm=NONE
|
||||
" highlight DiffChange ctermbg=DarkBlue ctermfg=white cterm=NONE
|
||||
" highlight DiffText ctermbg=DarkBlue ctermfg=white cterm=underline
|
||||
" highlight DiffDelete ctermbg=red ctermfg=white
|
||||
|
||||
if exists("loadedScmDiff") || &cp
|
||||
finish
|
||||
endif
|
||||
|
||||
let loadedScmDiff = 1
|
||||
|
||||
map <silent> <Leader>d :call <SID>scmToggle()<CR>
|
||||
noremap <unique> <script> <plug>Dh :call <SID>scmDiff("h")<CR>
|
||||
com! -bar -nargs=? D :call s:scmDiff(<f-args>)
|
||||
|
||||
let g:scmDiffRev = ''
|
||||
|
||||
function! s:scmToggle()
|
||||
|
||||
if exists('b:scmDiffOn') && b:scmDiffOn == 1
|
||||
let b:scmDiffOn = 0
|
||||
set nodiff
|
||||
exe 'bdelete ' . b:scmDiffTmpfile
|
||||
echohl DiffDelete | echon "scmdiff Disabled" | echohl None
|
||||
else
|
||||
call s:scmDiff()
|
||||
if exists('b:scmDiffOn') && b:scmDiffOn == 1
|
||||
echohl DiffAdd | echon "scmdiff Enabled" | echohl None
|
||||
endif
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:scmRefresh()
|
||||
|
||||
if exists('b:scmDiffOn') && b:scmDiffOn == 1
|
||||
call s:scmDiff()
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:detectSCM()
|
||||
|
||||
" Cache the results we find here to save time
|
||||
if exists("g:scmBufPath") && g:scmBufPath == expand("%:p:h") && exists("g:scmDiffCommand")
|
||||
return
|
||||
endif
|
||||
let g:scmBufPath = expand("%:p:h")
|
||||
|
||||
" Detect CVS, SCCS(bitkeeper) or .svn directories in current path
|
||||
if !exists("g:scmDiffCommand") && isdirectory(g:scmBufPath."/.svn")
|
||||
let g:scmDiffCommand = "svn diff"
|
||||
return
|
||||
endif
|
||||
|
||||
if !exists("g:scmDiffCommand") && isdirectory(g:scmBufPath."/CVS")
|
||||
let g:scmDiffCommand = "cvs diff"
|
||||
return
|
||||
endif
|
||||
|
||||
if !exists("g:scmDiffCommand") && isdirectory(g:scmBufPath."/SCCS")
|
||||
let g:scmDiffCommand = "bk diffs"
|
||||
return
|
||||
endif
|
||||
|
||||
" Detect .git, SCCS(bitkeeper), .hg(mercurial) directories recursively in reverse
|
||||
let my_path = g:scmBufPath
|
||||
while my_path != "/"
|
||||
if !exists("g:scmDiffCommand") && isdirectory(my_path."/.git")
|
||||
let g:scmDiffCommand = "git diff"
|
||||
return
|
||||
endif
|
||||
if !exists("g:scmDiffCommand") && isdirectory(my_path."/.hg")
|
||||
let g:scmDiffCommand = "hg diff"
|
||||
return
|
||||
endif
|
||||
let my_path = simplify(my_path."/../")
|
||||
endwhile
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:scmDiff(...)
|
||||
|
||||
call s:detectSCM()
|
||||
if (!exists("g:scmDiffCommand"))
|
||||
echohl WarningMsg | echon "Could not find .git, .svn, .hg, SCCS, or CVS directories, are you under a supported SCM repository path?" | echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
if exists('b:scmDiffOn') && b:scmDiffOn == 1
|
||||
let b:scmDiffOn = 0
|
||||
set nodiff
|
||||
exe 'bdelete ' . b:scmDiffTmpfile
|
||||
endif
|
||||
|
||||
let b:scmDiffOn = 1
|
||||
let view = winsaveview()
|
||||
|
||||
if a:0 == 1
|
||||
if a:1 == 'none'
|
||||
let g:scmDiffRev = ''
|
||||
else
|
||||
let g:scmDiffRev = a:1
|
||||
endif
|
||||
endif
|
||||
|
||||
let ftype = &filetype
|
||||
let b:scmDiffTmpfile = tempname()
|
||||
let cmd = 'cat ' . bufname('%') . ' > ' . b:scmDiffTmpfile
|
||||
let cmdOutput = system(cmd)
|
||||
let tmpdiff = tempname()
|
||||
let cmd = 'cd ' . g:scmBufPath . ' && ' . g:scmDiffCommand . ' ' . g:scmDiffRev . ' ' . expand('%:p') . ' > ' . tmpdiff
|
||||
let cmdOutput = system(cmd)
|
||||
|
||||
if v:shell_error && cmdOutput != ''
|
||||
echohl WarningMsg | echon cmdOutput | echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
let cmd = 'patch -R -p0 ' . b:scmDiffTmpfile . ' ' . tmpdiff
|
||||
let cmdOutput = system(cmd)
|
||||
|
||||
if v:shell_error && cmdOutput != ''
|
||||
echohl WarningMsg | echon cmdOutput | echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
if a:0 > 0 && a:1 == 'h'
|
||||
exe 'diffsplit' . b:scmDiffTmpfile
|
||||
else
|
||||
exe 'vert diffsplit' . b:scmDiffTmpfile
|
||||
endif
|
||||
|
||||
exe 'set filetype=' . ftype
|
||||
|
||||
hide
|
||||
|
||||
set foldcolumn=0
|
||||
set foldlevel=100
|
||||
set diffopt= " removed filler so we don't show deleted lines
|
||||
set noscrollbind
|
||||
|
||||
call winrestview(view)
|
||||
|
||||
endfunction
|
||||
|
||||
autocmd CursorHold * call s:scmRefresh()
|
||||
|
||||
|
||||
" vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker
|
||||
" vim<600: expandtab sw=4 ts=4 sts=4
|
||||
Loading…
Add table
Add a link
Reference in a new issue