Skip to content
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ In this example after every `composer install` I exec a ctags generation
This command open `composer.json`


```vim
:ComposerKnowWhereCurrentFileIs
```
This function aims to help you to load files without using ctag. Grep current word inside composer autogenerated files, and if only one occurrence is found, opens file in another tab. If zero or more occurrences are found, simply echoes a string to advice you. To use this in your .vimrc file, just remap function. For example you can use:

map <F6> :call ComposerKnowWhereCurrentFileIs()<CR>


## Install
```vim
Bundle 'vim-php/vim-composer'
Expand Down
14 changes: 14 additions & 0 deletions plugin/vim-composer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@ function! s:ComposerInstallFunc(arg)
exe "call ".g:composer_install_callback."()"
endif
endfunction

function! ComposerKnowWhereCurrentFileIs()
let l:currentWord = expand('<cword>')
let l:command = "grep " . l:currentWord . " ./vendor/composer -R | awk '{print $6}' | awk -F\\' '{print $2}'"
let l:commandFileFound = l:command . ' | wc -l'
let l:numberOfResults = system(l:commandFileFound)
if l:numberOfResults == 1
let l:fileName = system(l:command)
let l:openFileCommand = 'tabe ' g:project_path . l:fileName
exec l:openFileCommand
else
echo "No unique file found in composer's generated files"
endif
endfunction