Skip to content

Add 'cmd' option for plugin configuration #904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 23 additions & 2 deletions autoload/vundle/installer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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)
Expand All @@ -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


Expand Down
15 changes: 15 additions & 0 deletions doc/vundle.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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*

Expand Down
1 change: 1 addition & 0 deletions test/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down