Skip to content

Commit 4006ca8

Browse files
author
Simone Gentili
committed
Improved ComposerKnowWhereCurrentFileIs and readme file
1 parent da1ee23 commit 4006ca8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@ This command open `composer.json`
3232
```vim
3333
:ComposerKnowWhereCurrentFileIs
3434
```
35-
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:
35+
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
3636

37-
map <F6> :call ComposerKnowWhereCurrentFileIs()<CR>
37+
nnoremap <Leader>p :call g:ComposerKnowWhereCurrentFileIs()<CR>
38+
39+
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:
40+
41+
function! g:VimComposerCustomBehavior(currentWord)
42+
exec "normal \<c-p>" . a:currentWord
43+
endfunction
3844

3945

4046
## Install

plugin/vim-composer.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ function! g:ComposerKnowWhereCurrentFileIs()
6565
let l:openFileCommand = 'tabe .' . l:fileName
6666
exec l:openFileCommand
6767
else
68-
echo "No unique file found in composer's generated files"
68+
call g:VimComposerCustomBehavior(g:currentWord)
6969
endif
7070
endfunction

0 commit comments

Comments
 (0)