Skip to content

Commit a70741a

Browse files
author
Gianluca Arbezzano
committed
Merge pull request #10 from vim-php/feature/install_callback
Close #3 exec custom callback after composer install
2 parents 11b5035 + 27affbf commit a70741a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ This command exec the installation flow of composer's install. This process requ
1414
```vim
1515
:ComposerInstall [--no-dev ..]
1616
```
17-
This command exec `composer install`
17+
This command exec `composer install`. Now you can attach after this command a custom callback to exec your personal flow.
18+
```vim
19+
function! MyCallbackFunction()
20+
exec ':silent ! ctags -a %'
21+
endfunction
22+
let g:composer_install_callback = "MyCallbackFunction"
23+
```
24+
In this example after every `composer install` I exec a ctags generation
1825

1926
```vim
2027
:ComposerJSON
2128
```
2229
This command open `composer.json`
2330

31+
2432
## Install
2533
```vim
2634
Bundle 'vim-php/vim-composer'

plugin/vim-composer.vim

+13-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ if !exists("g:composer_cmd")
2121
endif
2222
endif
2323

24+
2425
command! -narg=* ComposerRun call s:ComposerRunFunc(<q-args>)
25-
command! -narg=* ComposerInstall call s:ComposerRunFunc("install ".<q-args>)
26+
command! -narg=* ComposerInstall call s:ComposerInstallFunc(<q-args>)
2627
command! ComposerGet call s:ComposerGetFunc()
2728
command! ComposerJSON call s:OpenComposerJSON()
2829

@@ -42,3 +43,14 @@ function! s:OpenComposerJSON()
4243
echo "Composer json doesn't exist"
4344
endif
4445
endfunction
46+
47+
if !exists("g:composer_install_callback")
48+
let g:composer_install_callback = ""
49+
endif
50+
51+
function! s:ComposerInstallFunc(arg)
52+
exe s:ComposerRunFunc("install")
53+
if len(g:composer_install_callback) > 0
54+
exe "call ".g:composer_install_callback."()"
55+
endif
56+
endfunction

0 commit comments

Comments
 (0)