Skip to content

Commit

Permalink
Merge pull request #10 from vim-php/feature/install_callback
Browse files Browse the repository at this point in the history
Close #3 exec custom callback after composer install
  • Loading branch information
Gianluca Arbezzano committed Apr 21, 2015
2 parents 11b5035 + 27affbf commit a70741a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
14 changes: 13 additions & 1 deletion plugin/vim-composer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ if !exists("g:composer_cmd")
endif
endif


command! -narg=* ComposerRun call s:ComposerRunFunc(<q-args>)
command! -narg=* ComposerInstall call s:ComposerRunFunc("install ".<q-args>)
command! -narg=* ComposerInstall call s:ComposerInstallFunc(<q-args>)
command! ComposerGet call s:ComposerGetFunc()
command! ComposerJSON call s:OpenComposerJSON()

Expand All @@ -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

0 comments on commit a70741a

Please sign in to comment.