Skip to content

Commit ca37140

Browse files
author
Simone Gentili
committed
Before ask to CtrlP, ComposerKnowWhereCurrentFileIs ask to composer
1 parent 4f44fe8 commit ca37140

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

plugin/vim-composer.vim

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,17 @@ function! s:ComposerInstallFunc(arg)
5555
endif
5656
endfunction
5757

58-
function! s:ComposerKnowWhereCurrentFileIs()
59-
let l:currentWord = explode('<cword>')
60-
exec "!grep ClassNameToFind ../onebip/vendor/composer -R | awk '{print $6}' | awk -F\' '{print $2}'"
58+
map <F6> :call ComposerKnowWhereCurrentFileIs()<CR>
59+
function! ComposerKnowWhereCurrentFileIs()
60+
let l:currentWord = expand('<cword>')
61+
let l:command = "grep " . l:currentWord . " vendor/composer -R | awk '{print $6}' | awk -F\\' '{print $2}'"
62+
let l:commandFileFound = l:command . ' | wc -l'
63+
let l:numberOfResults = system(l:commandFileFound)
64+
if l:numberOfResults == 1
65+
let l:fileName = system(l:command)
66+
let l:openFileCommand = 'tabe ' g:project_path . l:fileName
67+
exec l:openFileCommand
68+
else
69+
exec "normal \<c-p>" . expand('<cword>')
70+
endif
6171
endfunction

0 commit comments

Comments
 (0)