Skip to content

Improved ComposerKnowWhereCurrentFileIs and readme file #17

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
Jun 10, 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: 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