From 27affbfdd24fad389ed21550e0930ec1e47438d9 Mon Sep 17 00:00:00 2001 From: Gianluca Arbezzano Date: Tue, 21 Apr 2015 09:11:47 +0200 Subject: [PATCH] Close #3 exec custom callback after composer install --- README.md | 10 +++++++++- plugin/vim-composer.vim | 14 +++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1628225..41a62bd 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,21 @@ This command exec the installation flow of composer's install. This process requ ```vim :ComposerInstall [--no-dev ..] ``` -This command exec `composer install` +This command exec `composer install`. Now you can attach after this command a custom callback to exec your personal flow. +```vim +function! MyCallbackFunction() + exec ':silent ! ctags -a %' +endfunction +let g:composer_install_callback = "MyCallbackFunction" +``` +In this example after every `composer install` I exec a ctags generation ```vim :ComposerJSON ``` This command open `composer.json` + ## Install ```vim Bundle 'vim-php/vim-composer' diff --git a/plugin/vim-composer.vim b/plugin/vim-composer.vim index 4985648..7c657f3 100644 --- a/plugin/vim-composer.vim +++ b/plugin/vim-composer.vim @@ -21,8 +21,9 @@ if !exists("g:composer_cmd") endif endif + command! -narg=* ComposerRun call s:ComposerRunFunc() -command! -narg=* ComposerInstall call s:ComposerRunFunc("install ".) +command! -narg=* ComposerInstall call s:ComposerInstallFunc() command! ComposerGet call s:ComposerGetFunc() command! ComposerJSON call s:OpenComposerJSON() @@ -42,3 +43,14 @@ function! s:OpenComposerJSON() echo "Composer json doesn't exist" endif endfunction + +if !exists("g:composer_install_callback") + let g:composer_install_callback = "" +endif + +function! s:ComposerInstallFunc(arg) + exe s:ComposerRunFunc("install") + if len(g:composer_install_callback) > 0 + exe "call ".g:composer_install_callback."()" + endif +endfunction