From 8266c6b31d28c366f43c03247a3b60da0127da3a Mon Sep 17 00:00:00 2001 From: Petr Orlov Date: Sun, 28 Apr 2019 02:26:51 +0300 Subject: [PATCH] Add 'cmd' option for plugin configuration --- README.md | 4 ++++ autoload/vundle/installer.vim | 25 +++++++++++++++++++++++-- doc/vundle.txt | 15 +++++++++++++++ test/vimrc | 1 + 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 07e2f143..0458332c 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,10 @@ " Install L9 and avoid a Naming conflict if you've already installed a " different version somewhere else. " Plugin 'ascenator/L9', {'name': 'newL9'} + " + " Run an additional command after installation and updates. Some plugins + " require running build scripts to work properly. + Plugin 'workspace/custom', {'cmd': 'make'} " All of your Plugins must be added before the following line call vundle#end() " required diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 472271a3..adf0cfec 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -364,6 +364,27 @@ func! s:get_current_sha(bundle) endf +" --------------------------------------------------------------------------- +" Run user command script for a given bundle if defined +" +" bundle -- a bundle object +" return -- True if script succeed, False otherwise +" --------------------------------------------------------------------------- +func! s:run_user_cmd(bundle) + if has_key(a:bundle, 'cmd') + let cmd = [ + \ 'cd '.vundle#installer#shellesc(a:bundle.path()), + \ a:bundle.cmd, + \ ] + let cmd = join(cmd, ' && ') + let out = s:system(vundle#installer#shellesc_cd(cmd)) + call s:log(cmd, '$ ') + call s:log(out, '> ') + endif + return 0 == v:shell_error +endf + + " --------------------------------------------------------------------------- " Create the appropriate sync command to run according to the current state of " the local repository (clone, pull, reset, etc). @@ -457,7 +478,7 @@ func! s:sync(bang, bundle) abort end if empty(initial_sha) - return 'new' + return s:run_user_cmd(a:bundle) ? 'new' : 'error' endif let updated_sha = s:get_current_sha(a:bundle) @@ -467,7 +488,7 @@ func! s:sync(bang, bundle) abort endif call add(g:vundle#updated_bundles, [initial_sha, updated_sha, a:bundle]) - return 'updated' + return s:run_user_cmd(a:bundle) ? 'updated' : 'error' endf diff --git a/doc/vundle.txt b/doc/vundle.txt index 81a5f66f..86b92d78 100644 --- a/doc/vundle.txt +++ b/doc/vundle.txt @@ -96,6 +96,8 @@ more information. Plugin 'rstacruz/sparkup', {'rtp': 'vim/'} " Avoid a name conflict with L9 Plugin 'user/L9', {'name': 'newL9'} + " Run an additional command after installation and updates + Plugin 'workspace/custom', {'cmd': 'make'} " All of your Plugins must be added before the following line call vundle#end() " required @@ -193,6 +195,19 @@ Please note that the URI will be treated the same as for any other plugins, so only the last part of it will be added to the |runtimepath|. The user is advised to use this flag only with single word URIs to avoid confusion. +The 'cmd' option +---------------- + +An additional command script which runs right after installation and update +operation process. + +For example: +> + Plugin 'customplugin', {'cmd': './build all'} + +This can be usefull for complex plugins with requirements of post-install +builds, data importing, etc. All operations must not depend on user input. + 3.2 SUPPORTED URIS ~ *vundle-plugins-uris* diff --git a/test/vimrc b/test/vimrc index d8455a7e..2ea90786 100644 --- a/test/vimrc +++ b/test/vimrc @@ -51,6 +51,7 @@ Bundle '~/Dropbox/.gitrepos/utilz.vim.git' " with options Bundle 'rstacruz/sparkup.git', {'rtp': 'vim/'} Bundle 'matchit.zip', {'name': 'matchit'} +Bundle 'Valloric/YouCompleteMe', {'cmd': './install.py --clang-completer'} " Camel case Bundle 'vim-scripts/RubySinatra'