Skip to content

Commit

Permalink
Merge pull request #17 from sensorario/master
Browse files Browse the repository at this point in the history
Improved ComposerKnowWhereCurrentFileIs and readme file
  • Loading branch information
Gianluca Arbezzano committed Jun 10, 2015
2 parents da1ee23 + 4006ca8 commit 89239dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ 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:
Instead of use CtrlP directly, this function check if composer's autogenerated files contains exactly one occurrence of curent word. In this case, class file will be opened. CtrlP with current word is called instead. And because is CtrlP wrapper, we suggest to eventually remap the function with <Leader>p

map <F6> :call ComposerKnowWhereCurrentFileIs()<CR>
nnoremap <Leader>p :call g:ComposerKnowWhereCurrentFileIs()<CR>

If zero or more than one occurrences are found, ... a Customizable function will be called. This function is called VimComposerCustomBehavior(). When you press <Leader>p ComposerKnowWhereCurrentFileIs is called. If one file is found it will be opened. If not, this function is called with current word as parameter. If you want, you can call CtrlP. Here an example:

function! g:VimComposerCustomBehavior(currentWord)
exec "normal \<c-p>" . a:currentWord
endfunction


## Install
Expand Down
2 changes: 1 addition & 1 deletion plugin/vim-composer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ function! g:ComposerKnowWhereCurrentFileIs()
let l:openFileCommand = 'tabe .' . l:fileName
exec l:openFileCommand
else
echo "No unique file found in composer's generated files"
call g:VimComposerCustomBehavior(g:currentWord)
endif
endfunction

0 comments on commit 89239dc

Please sign in to comment.