diff --git a/vimfiles/GetLatest/GetLatestVimScripts.dat b/vimfiles/GetLatest/GetLatestVimScripts.dat index e1e6462..688b9c9 100644 --- a/vimfiles/GetLatest/GetLatestVimScripts.dat +++ b/vimfiles/GetLatest/GetLatestVimScripts.dat @@ -19,19 +19,19 @@ ScriptID SourceID Filename 1046 4249 Lusty Explorer 2043 7805 VimPdb (debugging python) 1776 7902 Vimgrep Replace -3745 16527 LineDiff +3745 16823 LineDiff 39 8196 matchit.vim 2092 8095 reloaded.vim (matrix colorscheme) 848 14668 SrchRplcHiGrp.vim (Search/Replace on Syntax Group) 294 10110 Align.vim 479 9276 MultipleSearch.vba 1066 7618 cecutil.vim -1173 15731 tComment.vim +1173 17289 tComment.vim 2701 13194 editsrec 3280 14334 Tabbi 642 15781 :AutoInstall: getscript.vim 1075 15782 :AutoInstall: netrw.vim 1502 15362 :AutoInstall: vimball.vim -3304 16172 Gundo -90 15797 vcscommand +3304 17406 Gundo +90 17031 vcscommand diff --git a/vimfiles/autoload/gundo.py b/vimfiles/autoload/gundo.py index aedc05e..21d66f0 100644 --- a/vimfiles/autoload/gundo.py +++ b/vimfiles/autoload/gundo.py @@ -553,7 +553,10 @@ def GundoPlayTo(): return None nodes.append(current) - return reversed(nodes) if rev else nodes + if rev: + return reversed(nodes) + else: + return nodes branch = _walk_branch(start, end) diff --git a/vimfiles/autoload/gundo.vim b/vimfiles/autoload/gundo.vim index 1b5de02..c0033a6 100644 --- a/vimfiles/autoload/gundo.vim +++ b/vimfiles/autoload/gundo.vim @@ -19,22 +19,6 @@ if v:version < '703'"{{{ finish endif"}}} -if has('python')"{{{ - let s:has_supported_python = 1 -else - let s:has_supported_python = 0 -endif - -if !s:has_supported_python - function! s:GundoDidNotLoad() - echohl WarningMsg|echomsg "Gundo requires Vim to be compiled with Python 2.4+"|echohl None - endfunction - command! -nargs=0 GundoToggle call s:GundoDidNotLoad() - finish -endif"}}} - -let s:plugin_path = escape(expand(':p:h'), '\') - if !exists('g:gundo_width')"{{{ let g:gundo_width = 45 endif"}}} @@ -59,7 +43,26 @@ endif"}}} if !exists("g:gundo_close_on_revert")"{{{ let g:gundo_close_on_revert = 0 endif"}}} +if !exists("g:gundo_prefer_python3")"{{{ + let g:gundo_prefer_python3 = 0 +endif"}}} +let s:has_supported_python = 0 +if g:gundo_prefer_python3 && has('python3')"{{{ + let s:has_supported_python = 2 +elseif has('python')" + let s:has_supported_python = 1 +endif + +if !s:has_supported_python + function! s:GundoDidNotLoad() + echohl WarningMsg|echomsg "Gundo requires Vim to be compiled with Python 2.4+"|echohl None + endfunction + command! -nargs=0 GundoToggle call s:GundoDidNotLoad() + finish +endif"}}} + +let s:plugin_path = escape(expand(':p:h'), '\') "}}} "{{{ Gundo utility functions @@ -213,6 +216,9 @@ function! s:GundoOpenGraph()"{{{ call s:GundoResizeBuffers(winnr()) endif endif + if exists("g:gundo_tree_statusline") + let &l:statusline = g:gundo_tree_statusline + endif endfunction"}}} function! s:GundoOpenPreview()"{{{ @@ -247,6 +253,9 @@ function! s:GundoOpenPreview()"{{{ endif endif endif + if exists("g:gundo_preview_statusline") + let &l:statusline = g:gundo_preview_statusline + endif endfunction"}}} function! s:GundoClose()"{{{ @@ -263,8 +272,13 @@ endfunction"}}} function! s:GundoOpen()"{{{ if !exists('g:gundo_py_loaded') - exe 'pyfile ' . s:plugin_path . '/gundo.py' - python initPythonModule() + if s:has_supported_python == 2 && g:gundo_prefer_python3 + exe 'py3file ' . s:plugin_path . '/gundo.py' + python3 initPythonModule() + else + exe 'pyfile ' . s:plugin_path . '/gundo.py' + python initPythonModule() + endif if !s:has_supported_python function! s:GundoDidNotLoad() @@ -303,6 +317,14 @@ function! s:GundoToggle()"{{{ endif endfunction"}}} +function! s:GundoShow()"{{{ + call s:GundoOpen() +endfunction"}}} + +function! s:GundoHide()"{{{ + call s:GundoClose() +endfunction"}}} + "}}} "{{{ Gundo mouse handling @@ -363,15 +385,27 @@ endfunction"}}} "{{{ Gundo rendering function! s:GundoRenderGraph()"{{{ - python GundoRenderGraph() + if s:has_supported_python == 2 && g:gundo_prefer_python3 + python3 GundoRenderGraph() + else + python GundoRenderGraph() + endif endfunction"}}} function! s:GundoRenderPreview()"{{{ - python GundoRenderPreview() + if s:has_supported_python == 2 && g:gundo_prefer_python3 + python3 GundoRenderPreview() + else + python GundoRenderPreview() + endif endfunction"}}} function! s:GundoRenderChangePreview()"{{{ - python GundoRenderChangePreview() + if s:has_supported_python == 2 && g:gundo_prefer_python3 + python3 GundoRenderChangePreview() + else + python GundoRenderChangePreview() + endif endfunction"}}} "}}} @@ -379,11 +413,19 @@ endfunction"}}} "{{{ Gundo undo/redo function! s:GundoRevert()"{{{ - python GundoRevert() + if s:has_supported_python == 2 && g:gundo_prefer_python3 + python3 GundoRevert() + else + python GundoRevert() + endif endfunction"}}} function! s:GundoPlayTo()"{{{ - python GundoPlayTo() + if s:has_supported_python == 2 && g:gundo_prefer_python3 + python3 GundoPlayTo() + else + python GundoPlayTo() + endif endfunction"}}} "}}} @@ -404,4 +446,4 @@ augroup GundoAug autocmd BufNewFile __Gundo_Preview__ call s:GundoSettingsPreview() augroup END -"}}} \ No newline at end of file +"}}} diff --git a/vimfiles/autoload/linediff/differ.vim b/vimfiles/autoload/linediff/differ.vim index 3afd405..7eb5c9d 100644 --- a/vimfiles/autoload/linediff/differ.vim +++ b/vimfiles/autoload/linediff/differ.vim @@ -98,10 +98,10 @@ function! linediff#differ#SetupDiffBuffer() dict let b:differ = self let statusline = printf('[%s:%%{b:differ.from}-%%{b:differ.to}]', bufname(self.original_buffer)) - if &statusline =~ '%f' - let statusline = substitute(&statusline, '%f', statusline, '') + if &statusline =~ '%[fF]' + let statusline = substitute(&statusline, '%[fF]', statusline, '') endif - exe "setlocal statusline=" . escape(statusline, ' ') + exe "setlocal statusline=" . escape(statusline, ' |') exe "set filetype=" . self.filetype setlocal bufhidden=hide @@ -109,7 +109,9 @@ function! linediff#differ#SetupDiffBuffer() dict endfunction function! linediff#differ#CloseDiffBuffer() dict - exe "bdelete ".self.diff_buffer + if bufexists(self.diff_buffer) + exe "bdelete ".self.diff_buffer + endif endfunction function! linediff#differ#SetupSigns() dict diff --git a/vimfiles/doc/gundo.txt b/vimfiles/doc/gundo.txt index f05989b..ee9a0d4 100644 --- a/vimfiles/doc/gundo.txt +++ b/vimfiles/doc/gundo.txt @@ -17,6 +17,8 @@ CONTENTS *Gundo-contents* 3.7 gundo_map_move_older ...... |gundo_map_move_older| gundo_map_move_newer ...... |gundo_map_move_newer| 3.8 gundo_close_on_revert ..... |gundo_close_on_revert| + 3.9 gundo_preview_statusline .. |gundo_preview_statusline| + gundo_tree_statusline ..... |gundo_tree_statusline| 4. License ........................ |GundoLicense| 5. Bugs ........................... |GundoBugs| 6. Contributing ................... |GundoContributing| @@ -196,6 +198,14 @@ Set this to 1 to automatically close the Gundo windows when reverting. Default: 0 (windows do not automatically close) +------------------------------------------------------------------------------ +3.9 g:gundo_preview_statusline *gundo_preview_statusline* + g:gundo_tree_statusline *gundo_tree_statusline* + +Set these to a string to display it as the status line for each Gundo window. + +Default: unset (windows use the default statusline) + ============================================================================== 4. License *GundoLicense* @@ -219,6 +229,8 @@ GitHub: http://github.com/sjl/gundo.vim/ ============================================================================== 7. Changelog *GundoChangelog* +v2.3.0 + * Add statusline configuration. v2.2.2 * More performance improvements. v2.2.1 diff --git a/vimfiles/doc/tags b/vimfiles/doc/tags index 0783b0b..84edcd0 100644 --- a/vimfiles/doc/tags +++ b/vimfiles/doc/tags @@ -133,6 +133,7 @@ VCSCommandSVNDiffOpt vcscommand.txt /*VCSCommandSVNDiffOpt* VCSCommandSVNExec vcscommand.txt /*VCSCommandSVNExec* VCSCommandSplit vcscommand.txt /*VCSCommandSplit* VCSCommandVCSTypeOverride vcscommand.txt /*VCSCommandVCSTypeOverride* +VCSCommandVCSTypePreference vcscommand.txt /*VCSCommandVCSTypePreference* VimPdb.txt VimPdb.txt /*VimPdb.txt* Vimball-copyright pi_vimball.txt /*Vimball-copyright* [% matchit.txt /*[%* @@ -1629,7 +1630,9 @@ gundo_map_move_newer gundo.txt /*gundo_map_move_newer* gundo_map_move_older gundo.txt /*gundo_map_move_older* gundo_preview_bottom gundo.txt /*gundo_preview_bottom* gundo_preview_height gundo.txt /*gundo_preview_height* +gundo_preview_statusline gundo.txt /*gundo_preview_statusline* gundo_right gundo.txt /*gundo_right* +gundo_tree_statusline gundo.txt /*gundo_tree_statusline* gundo_width gundo.txt /*gundo_width* http pi_netrw.txt /*http* linediff linediff.txt /*linediff* diff --git a/vimfiles/doc/vcscommand.txt b/vimfiles/doc/vcscommand.txt index 5e0c4c0..f56e7ef 100644 --- a/vimfiles/doc/vcscommand.txt +++ b/vimfiles/doc/vcscommand.txt @@ -447,6 +447,7 @@ The following variables are available: |VCSCommandSVNDiffOpt| |VCSCommandSVNExec| |VCSCommandVCSTypeOverride| +|VCSCommandVCSTypePreference| VCSCommandCommitOnWrite *VCSCommandCommitOnWrite* @@ -593,6 +594,13 @@ element is a regular expression that will be matched against the full file name of a given buffer. If it matches, the second element will be used as the VCS type. +VCSCommandVCSTypePreference *VCSCommandVCSTypePreference* + +This variable allows the VCS type detection to be weighted towards a specific +VCS, in case more than one potential VCS is detected as useable. The format +of the variable is either a list or a space-separated string containing the +ordered-by-preference abbreviations of the preferred VCS types. + 5.2 VCSCommand events *vcscommand-events* For additional customization, vcscommand can trigger user-defined events. diff --git a/vimfiles/plugin/gundo.vim b/vimfiles/plugin/gundo.vim index fe2a200..ed59293 100644 --- a/vimfiles/plugin/gundo.vim +++ b/vimfiles/plugin/gundo.vim @@ -18,5 +18,7 @@ let loaded_gundo = 1"}}} "{{{ Misc command! -nargs=0 GundoToggle call gundo#GundoToggle() +command! -nargs=0 GundoShow call gundo#GundoShow() +command! -nargs=0 GundoHide call gundo#GundoHide() command! -nargs=0 GundoRenderGraph call gundo#GundoRenderGraph() -"}}} \ No newline at end of file +"}}} diff --git a/vimfiles/plugin/linediff.vim b/vimfiles/plugin/linediff.vim index 9be4a87..f154d6d 100644 --- a/vimfiles/plugin/linediff.vim +++ b/vimfiles/plugin/linediff.vim @@ -2,15 +2,12 @@ if exists("g:loaded_linediff") || &cp finish endif -let g:loaded_linediff = '0.1.0' " version number +let g:loaded_linediff = '0.1.1' " version number let s:keepcpo = &cpo set cpo&vim " Initialized lazily to avoid executing the autoload file before it's really " needed. -" -" TODO Experiment to see if this matters at all. -" function! s:Init() if !exists('s:differ_one') let s:differ_one = linediff#differ#New('linediff_one', 1) diff --git a/vimfiles/plugin/vcsbzr.vim b/vimfiles/plugin/vcsbzr.vim index 877990d..966f2ee 100644 --- a/vimfiles/plugin/vcsbzr.vim +++ b/vimfiles/plugin/vcsbzr.vim @@ -43,7 +43,9 @@ if v:version < 700 finish endif -runtime plugin/vcscommand.vim +if !exists('g:loaded_VCSCommand') + runtime plugin/vcscommand.vim +endif if !executable(VCSCommandGetOption('VCSCommandBZRExec', 'bzr')) " BZR is not installed @@ -105,7 +107,7 @@ endfunction " Function: s:bzrFunctions.Annotate(argList) {{{2 function! s:bzrFunctions.Annotate(argList) if len(a:argList) == 0 - if &filetype == 'BZRannotate' + 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 diff --git a/vimfiles/plugin/vcscommand.vim b/vimfiles/plugin/vcscommand.vim index 92884d9..2726436 100644 --- a/vimfiles/plugin/vcscommand.vim +++ b/vimfiles/plugin/vcscommand.vim @@ -272,6 +272,13 @@ " full file name of a given buffer. If it matches, the second element will " be used as the VCS type. " +" VCSCommandVCSTypePreference +" This variable allows the VCS type detection to be weighted towards a +" specific VCS, in case more than one potential VCS is detected as useable. +" The format of the variable is either a list or a space-separated string +" containing the ordered-by-preference abbreviations of the preferred VCS +" types. +" " Event documentation {{{2 " For additional customization, VCSCommand.vim uses User event autocommand " hooks. Each event is in the VCSCommand group, and different patterns @@ -350,8 +357,8 @@ let s:VCSCommandUtility = {} " plugin-specific information: {vcs -> [script, {command -> function}, {key -> mapping}]} let s:plugins = {} -" temporary values of overridden configuration variables -let s:optionOverrides = {} +" Stack of dictionaries representing nested options +let s:executionContext = [] " state flag used to vary behavior of certain automated actions let s:isEditFileRunning = 0 @@ -376,15 +383,27 @@ function! s:VCSCommandUtility.system(...) set sxq=\" endif try - if exists('*iconv') - return iconv(call('system', a:000), &tenc, &enc) + let output = call('system', a:000) + if exists('*iconv') && has('multi_byte') + if(strlen(&tenc) && &tenc != &enc) + let output = iconv(output, &tenc, &enc) + else + let originalBuffer = VCSCommandGetOriginalBuffer(VCSCommandGetOption('VCSCommandEncodeAsFile', 0)) + if originalBuffer + let fenc = getbufvar(originalBuffer, '&fenc') + if fenc != &enc + let output = iconv(output, fenc, &enc) + endif + endif + endif + endif - return call('system', a:000) finally if exists("save_sxq") let &sxq = save_sxq endif endtry + return output endfunction " Function: s:VCSCommandUtility.addMenuItem(shortcut, command) {{{2 @@ -396,6 +415,20 @@ function! s:VCSCommandUtility.addMenuItem(shortcut, command) endif endfunction +" Function: s:VCSCommandUtility.pushContext(context) {{{2 +" Adds a dictionary containing current options to the stack. + +function! s:VCSCommandUtility.pushContext(context) + call insert(s:executionContext, a:context) +endfunction + +" Function: s:VCSCommandUtility.popContext() {{{2 +" Removes a dictionary containing current options from the stack. + +function! s:VCSCommandUtility.popContext() + call remove(s:executionContext, 0) +endfunction + " Function: s:ClearMenu() {{{2 " Removes all VCSCommand menu items function! s:ClearMenu() @@ -545,6 +578,64 @@ function! s:EditFile(command, originalBuffer, statusText) endtry endfunction +" Function: s:IdentifyVCSType() {{{2 +" This function implements the non-cached identification strategy for +" VcsCommandGetVCSType(). +" +" Returns: VCS type name identified for the given buffer; an exception is +" thrown in case no type can be identified. + +function! s:IdentifyVCSType(buffer) + if exists("g:VCSCommandVCSTypeOverride") + let fullpath = fnamemodify(bufname(a:buffer), ':p') + for [path, vcsType] in g:VCSCommandVCSTypeOverride + if match(fullpath, path) > -1 + return vcsType + endif + endfor + endif + let matches = [] + let exactMatch = '' + let exactMatchCount = 0 + for vcsType in keys(s:plugins) + let identified = s:plugins[vcsType][1].Identify(a:buffer) + if identified + if identified == g:VCSCOMMAND_IDENTIFY_EXACT + let exactMatch = vcsType + let exactMatchCount += 1 + endif + call add(matches, [vcsType, identified]) + endif + endfor + if len(matches) == 1 + return matches[0][0] + elseif len(matches) == 0 + throw 'No suitable plugin' + else + let preferences = VCSCommandGetOption("VCSCommandVCSTypePreference", []) + if len(preferences) > 0 + if type(preferences) == 1 + let listPreferences = split(preferences, '\W\+') + unlet preferences + let preferences = listPreferences + endif + for preferred in preferences + for [vcsType, identified] in matches + if vcsType ==? preferred + return vcsType + endif + endfor + endfor + endif + + if exactMatchCount == 1 + return exactMatch + endif + + throw 'can''t identify VCS type for current buffer due to too many matching VCS: ' . join(map(matches, 'v:val[0]')) + endif +endfunction + " Function: s:SetupScratchBuffer(command, vcsType, originalBuffer, statusText) {{{2 " Creates convenience buffer variables and the name of a vcscommand result " buffer. @@ -625,21 +716,6 @@ function! s:MarkOrigBufferForSetup(buffer) return a:buffer endfunction -" Function: s:OverrideOption(option, [value]) {{{2 -" Provides a temporary override for the given VCS option. If no value is -" passed, the override is disabled. - -function! s:OverrideOption(option, ...) - if a:0 == 0 - call remove(s:optionOverrides[a:option], -1) - else - if !has_key(s:optionOverrides, a:option) - let s:optionOverrides[a:option] = [] - endif - call add(s:optionOverrides[a:option], a:1) - endif -endfunction - " Function: s:WipeoutCommandBuffers() {{{2 " Clears all current VCS output buffers of the specified type for a given source. @@ -721,6 +797,7 @@ endfunction " Function: s:VCSAnnotate(...) {{{2 function! s:VCSAnnotate(bang, ...) + call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')}) try let line = line('.') let currentBuffer = bufnr('%') @@ -741,9 +818,18 @@ function! s:VCSAnnotate(bang, ...) if splitRegex == '' return annotateBuffer endif + wincmd J let originalFileType = getbufvar(originalBuffer, '&ft') let annotateFileType = getbufvar(annotateBuffer, '&ft') - execute "normal! 0zR\G/" . splitRegex . "/e\d" + + let saveselection = &selection + set selection=inclusive + try + execute "normal! 0zR\G/" . splitRegex . "/e\d" + finally + let &selection = saveselection + endtry + call setbufvar('%', '&filetype', getbufvar(originalBuffer, '&filetype')) set scrollbind leftabove vert new @@ -774,6 +860,8 @@ function! s:VCSAnnotate(bang, ...) catch call s:ReportError(v:exception) return -1 + finally + call s:VCSCommandUtility.popContext() endtry endfunction @@ -841,6 +929,11 @@ endfunction " Function: s:VCSFinishCommit(logMessageList, originalBuffer) {{{2 function! s:VCSFinishCommit(logMessageList, originalBuffer) let messageFileName = tempname() + if exists('*iconv') && has('multi_byte') + if(strlen(&tenc) && &tenc != &enc) + call map(a:logMessageList, 'iconv(v:val, &enc, &tenc)') + endif + endif call writefile(a:logMessageList, messageFileName) try let resultBuffer = s:ExecuteVCSCommand('Commit', [messageFileName]) @@ -877,21 +970,31 @@ function! s:VCSGotoOriginal(bang) endfunction function! s:VCSDiff(...) "{{{2 - let resultBuffer = s:ExecuteVCSCommand('Diff', a:000) - if resultBuffer > 0 - let &filetype = 'diff' - elseif resultBuffer == 0 - echomsg 'No differences found' - endif - return resultBuffer + call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')}) + try + let resultBuffer = s:ExecuteVCSCommand('Diff', a:000) + if resultBuffer > 0 + let &filetype = 'diff' + elseif resultBuffer == 0 + echomsg 'No differences found' + endif + return resultBuffer + finally + call s:VCSCommandUtility.popContext() + endtry endfunction function! s:VCSReview(...) "{{{2 - let resultBuffer = s:ExecuteVCSCommand('Review', a:000) - if resultBuffer > 0 - let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype') - endif - return resultBuffer + call s:VCSCommandUtility.pushContext({'VCSCommandEncodeAsFile': bufnr('%')}) + try + let resultBuffer = s:ExecuteVCSCommand('Review', a:000) + if resultBuffer > 0 + let &filetype = getbufvar(b:VCSCommandOriginalBuffer, '&filetype') + endif + return resultBuffer + finally + call s:VCSCommandUtility.popContext() + endtry endfunction " Function: s:VCSVimDiff(...) {{{2 @@ -931,11 +1034,11 @@ function! s:VCSVimDiff(...) diffthis let t:vcsCommandVimDiffScratchList = [resultBuffer] " If no split method is defined, cheat, and set it to vertical. + call s:VCSCommandUtility.pushContext({'VCSCommandSplit': orientation}) try - call s:OverrideOption('VCSCommandSplit', orientation) let resultBuffer = s:VCSReview(a:2) finally - call s:OverrideOption('VCSCommandSplit') + call s:VCSCommandUtility.popContext() endtry if resultBuffer < 0 echomsg 'Can''t open revision ' . a:1 @@ -945,22 +1048,16 @@ function! s:VCSVimDiff(...) diffthis let t:vcsCommandVimDiffScratchList += [resultBuffer] else - " Add new buffer - call s:OverrideOption('VCSCommandEdit', 'split') + " Add new buffer. Force splitting behavior, otherwise why use vimdiff? + call s:VCSCommandUtility.pushContext({'VCSCommandEdit': 'split', 'VCSCommandSplit': orientation}) try - " Force splitting behavior, otherwise why use vimdiff? - call s:OverrideOption('VCSCommandSplit', orientation) - try - if(a:0 == 0) - let resultBuffer = s:VCSReview() - else - let resultBuffer = s:VCSReview(a:1) - endif - finally - call s:OverrideOption('VCSCommandSplit') - endtry + if(a:0 == 0) + let resultBuffer = s:VCSReview() + else + let resultBuffer = s:VCSReview(a:1) + endif finally - call s:OverrideOption('VCSCommandEdit') + call s:VCSCommandUtility.popContext() endtry if resultBuffer < 0 echomsg 'Can''t open current revision' @@ -985,9 +1082,11 @@ function! s:VCSVimDiff(...) \ . '|call setbufvar('.originalBuffer.', ''&foldmethod'', '''.getbufvar(originalBuffer, '&foldmethod').''')' \ . '|call setbufvar('.originalBuffer.', ''&foldlevel'', '''.getbufvar(originalBuffer, '&foldlevel').''')' \ . '|call setbufvar('.originalBuffer.', ''&scrollbind'', '.getbufvar(originalBuffer, '&scrollbind').')' - \ . '|call setbufvar('.originalBuffer.', ''&cursorbind'', '.getbufvar(originalBuffer, '&cursorbind').')' \ . '|call setbufvar('.originalBuffer.', ''&wrap'', '.getbufvar(originalBuffer, '&wrap').')' - \ . '|if &foldmethod==''manual''|execute ''normal! zE''|endif' + if has('cursorbind') + let t:vcsCommandVimDiffRestoreCmd .= '|call setbufvar('.originalBuffer.', ''&cursorbind'', '.getbufvar(originalBuffer, '&cursorbind').')' + endif + let t:vcsCommandVimDiffRestoreCmd .= '|if &foldmethod==''manual''|execute ''normal! zE''|endif' diffthis wincmd w else @@ -1021,49 +1120,31 @@ endfunction " Section: Public functions {{{1 " Function: VCSCommandGetVCSType() {{{2 -" Sets the b:VCSCommandVCSType variable in the given buffer to the -" appropriate source control system name. +" This function sets the b:VCSCommandVCSType variable in the given buffer to the +" appropriate source control system name and returns the same name. " -" This uses the Identify extension function to test the buffer. If the -" Identify function returns VCSCOMMAND_IDENTIFY_EXACT, the match is considered -" exact. If the Identify function returns VCSCOMMAND_IDENTIFY_INEXACT, the -" match is considered inexact, and is only applied if no exact match is found. -" Multiple inexact matches is currently considered an error. +" Returns: VCS type name identified for the given buffer. An exception is +" thrown if no type can be identified. +" +" Rules for determining type: +" 1. use previously-cached value +" 2. use value from 'VCSCommandVCSTypeOverride' +" 3. use single match +" 4. use first matching value from 'VCSCommandTypePreference' +" 5. use single exact match +" 6. error if multiple matching types +" 7. error if no matching types function! VCSCommandGetVCSType(buffer) - let vcsType = getbufvar(a:buffer, 'VCSCommandVCSType') - if strlen(vcsType) > 0 - return vcsType - endif - if exists("g:VCSCommandVCSTypeOverride") - let fullpath = fnamemodify(bufname(a:buffer), ':p') - for [path, vcsType] in g:VCSCommandVCSTypeOverride - if match(fullpath, path) > -1 - call setbufvar(a:buffer, 'VCSCommandVCSType', vcsType) - return vcsType - endif - endfor - endif - let matches = [] - for vcsType in keys(s:plugins) - let identified = s:plugins[vcsType][1].Identify(a:buffer) - if identified - if identified == g:VCSCOMMAND_IDENTIFY_EXACT - let matches = [vcsType] - break - else - let matches += [vcsType] - endif + let vcsType = VCSCommandGetOption('VCSCommandVCSTypeExplicitOverride', '') + if len(vcsType) == 0 + let vcsType = getbufvar(a:buffer, 'VCSCommandVCSType') + if strlen(vcsType) == 0 + let vcsType = s:IdentifyVCSType(a:buffer) + call setbufvar(a:buffer, 'VCSCommandVCSType', vcsType) endif - endfor - if len(matches) == 1 - call setbufvar(a:buffer, 'VCSCommandVCSType', matches[0]) - return matches[0] - elseif len(matches) == 0 - throw 'No suitable plugin' - else - throw 'Too many matching VCS: ' . join(matches) endif + return vcsType endfunction " Function: VCSCommandChdir(directory) {{{2 @@ -1074,7 +1155,11 @@ function! VCSCommandChdir(directory) if exists("*haslocaldir") && haslocaldir() let command = 'lcd' endif - execute command fnameescape(a:directory) + if exists("*fnameescape") + execute command fnameescape(a:directory) + else + execute command escape(a:directory, ' ') + endif endfunction " Function: VCSCommandChangeToCurrentFileDir() {{{2 @@ -1226,9 +1311,12 @@ endfunction " searched in the window, buffer, then global spaces. function! VCSCommandGetOption(name, default) - if has_key(s:optionOverrides, a:name) && len(s:optionOverrides[a:name]) > 0 - return s:optionOverrides[a:name][-1] - elseif exists('w:' . a:name) + for context in s:executionContext + if has_key(context, a:name) + return context[a:name] + endif + endfor + if exists('w:' . a:name) return w:{a:name} elseif exists('b:' . a:name) return b:{a:name} diff --git a/vimfiles/plugin/vcscvs.vim b/vimfiles/plugin/vcscvs.vim index 53e6770..11c7433 100644 --- a/vimfiles/plugin/vcscvs.vim +++ b/vimfiles/plugin/vcscvs.vim @@ -89,7 +89,9 @@ if v:version < 700 finish endif -runtime plugin/vcscommand.vim +if !exists('g:loaded_VCSCommand') + runtime plugin/vcscommand.vim +endif if !executable(VCSCommandGetOption('VCSCommandCVSExec', 'cvs')) " CVS is not installed @@ -180,7 +182,7 @@ endfunction " Function: s:cvsFunctions.Annotate(argList) {{{2 function! s:cvsFunctions.Annotate(argList) if len(a:argList) == 0 - if &filetype == 'CVSannotate' + 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.]+') diff --git a/vimfiles/plugin/vcsgit.vim b/vimfiles/plugin/vcsgit.vim index b440565..2667982 100644 --- a/vimfiles/plugin/vcsgit.vim +++ b/vimfiles/plugin/vcsgit.vim @@ -48,7 +48,9 @@ if v:version < 700 finish endif -runtime plugin/vcscommand.vim +if !exists('g:loaded_VCSCommand') + runtime plugin/vcscommand.vim +endif if !executable(VCSCommandGetOption('VCSCommandGitExec', 'git')) " git is not installed diff --git a/vimfiles/plugin/vcshg.vim b/vimfiles/plugin/vcshg.vim index e9e894a..775ede0 100644 --- a/vimfiles/plugin/vcshg.vim +++ b/vimfiles/plugin/vcshg.vim @@ -50,7 +50,9 @@ if v:version < 700 finish endif -runtime plugin/vcscommand.vim +if !exists('g:loaded_VCSCommand') + runtime plugin/vcscommand.vim +endif if !executable(VCSCommandGetOption('VCSCommandHGExec', 'hg')) " HG is not installed @@ -110,10 +112,10 @@ endfunction " Function: s:hgFunctions.Annotate(argList) {{{2 function! s:hgFunctions.Annotate(argList) if len(a:argList) == 0 - if &filetype == 'HGannotate' + 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 + let caption = matchstr(getline('.'),'\v^\s*\w+\s+\zs\d+') + let options = ' -un -r' . caption else let caption = '' let options = ' -un' diff --git a/vimfiles/plugin/vcssvk.vim b/vimfiles/plugin/vcssvk.vim index b58b603..bee84c3 100644 --- a/vimfiles/plugin/vcssvk.vim +++ b/vimfiles/plugin/vcssvk.vim @@ -43,7 +43,9 @@ if v:version < 700 finish endif -runtime plugin/vcscommand.vim +if !exists('g:loaded_VCSCommand') + runtime plugin/vcscommand.vim +endif if !executable(VCSCommandGetOption('VCSCommandSVKExec', 'svk')) " SVK is not installed @@ -104,7 +106,7 @@ endfunction " Function: s:svkFunctions.Annotate(argList) {{{2 function! s:svkFunctions.Annotate(argList) if len(a:argList) == 0 - if &filetype == 'SVKannotate' + 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 diff --git a/vimfiles/plugin/vcssvn.vim b/vimfiles/plugin/vcssvn.vim index 30f7a24..8ad6388 100644 --- a/vimfiles/plugin/vcssvn.vim +++ b/vimfiles/plugin/vcssvn.vim @@ -50,7 +50,9 @@ if v:version < 700 finish endif -runtime plugin/vcscommand.vim +if !exists('g:loaded_VCSCommand') + runtime plugin/vcscommand.vim +endif if !executable(VCSCommandGetOption('VCSCommandSVNExec', 'svn')) " SVN is not installed @@ -89,22 +91,17 @@ endfunction " 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 + let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer))) + try + call s:VCSCommandUtility.system(s:Executable() . ' info .') + if(v:shell_error) + return 0 + else + return g:VCSCOMMAND_IDENTIFY_EXACT + endif + finally + call VCSCommandChdir(oldCwd) + endtry endfunction " Function: s:svnFunctions.Add() {{{2 @@ -115,7 +112,7 @@ endfunction " Function: s:svnFunctions.Annotate(argList) {{{2 function! s:svnFunctions.Annotate(argList) if len(a:argList) == 0 - if &filetype == 'SVNannotate' + 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 @@ -187,7 +184,7 @@ endfunction function! s:svnFunctions.GetBufferInfo() let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) let fileName = bufname(originalBuffer) - let statusText = s:VCSCommandUtility.system(s:Executable() . ' status --non-interactive -vu -- "' . fileName . '"') + let statusText = s:VCSCommandUtility.system(s:Executable() . ' status --non-interactive -v -- "' . fileName . '"') if(v:shell_error) return [] endif