From 58a9b3baf6bbf0a5e01d94654c7b210cdcd074e2 Mon Sep 17 00:00:00 2001 From: Will Palmer Date: Thu, 3 Feb 2011 06:01:00 -0600 Subject: [PATCH] allow "preferred vcs" in case of ambiguity --- plugin/vcscommand.vim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugin/vcscommand.vim b/plugin/vcscommand.vim index 42b1849..1715371 100644 --- a/plugin/vcscommand.vim +++ b/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 a string containing the abbreviations of the +" preferred VCS types, separated by spaces. eg: 'git bzr cvs'. When there is +" ambiguity as to which VCS should be used. +" " Event documentation {{{2 " For additional customization, VCSCommand.vim uses User event autocommand " hooks. Each event is in the VCSCommand group, and different patterns @@ -1062,6 +1069,17 @@ function! VCSCommandGetVCSType(buffer) elseif len(matches) == 0 throw 'No suitable plugin' else + if exists("g:VCSCommandVCSTypePreference") + for preferred in split(g:VCSCommandVCSTypePreference, '\W\+') + echo preferred + for vcsType in matches + if toupper(vcsType) == toupper(preferred) + call setbufvar(a:buffer, 'VCSCommandVCSType', vcsType) + return vcsType + endif + endfor + endfor + endif throw 'Too many matching VCS: ' . join(matches) endif endfunction -- 2.11.4.GIT