Skip to content

Close #3 exec custom callback after composer install #10

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

Merged
merged 1 commit into from
Apr 21, 2015
Merged
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
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