From 4f44fe8a1663eab4205867fcb1cd9270d9a2e736 Mon Sep 17 00:00:00 2001 From: Simone Date: Sat, 16 May 2015 22:47:00 +0200 Subject: [PATCH 1/6] Update vim-composer.vim --- plugin/vim-composer.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/vim-composer.vim b/plugin/vim-composer.vim index 7c657f3..fa8a778 100644 --- a/plugin/vim-composer.vim +++ b/plugin/vim-composer.vim @@ -54,3 +54,8 @@ function! s:ComposerInstallFunc(arg) exe "call ".g:composer_install_callback."()" endif endfunction + +function! s:ComposerKnowWhereCurrentFileIs() + let l:currentWord = explode('') + exec "!grep ClassNameToFind ../onebip/vendor/composer -R | awk '{print $6}' | awk -F\' '{print $2}'" +endfunction From ca3714095ada43a73be7e22c278dba82ae4b0402 Mon Sep 17 00:00:00 2001 From: Simone Gentili Date: Fri, 22 May 2015 13:48:43 +0200 Subject: [PATCH 2/6] Before ask to CtrlP, ComposerKnowWhereCurrentFileIs ask to composer --- plugin/vim-composer.vim | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plugin/vim-composer.vim b/plugin/vim-composer.vim index fa8a778..71aa452 100644 --- a/plugin/vim-composer.vim +++ b/plugin/vim-composer.vim @@ -55,7 +55,17 @@ function! s:ComposerInstallFunc(arg) endif endfunction -function! s:ComposerKnowWhereCurrentFileIs() - let l:currentWord = explode('') - exec "!grep ClassNameToFind ../onebip/vendor/composer -R | awk '{print $6}' | awk -F\' '{print $2}'" +map :call ComposerKnowWhereCurrentFileIs() +function! ComposerKnowWhereCurrentFileIs() + let l:currentWord = expand('') + 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 + exec "normal \" . expand('') + endif endfunction From d4d990478715d4dce1954feb1f66bbe564fa0b64 Mon Sep 17 00:00:00 2001 From: Simone Gentili Date: Tue, 26 May 2015 07:52:24 +0200 Subject: [PATCH 3/6] Considered current as the vendor folder Instead of directly open ctrlp with current word, ComposerKnowWhereCurrentFileIs show a message that explain that there is not only one occurency of cword in composer auto-generated files. --- plugin/vim-composer.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vim-composer.vim b/plugin/vim-composer.vim index 71aa452..6e69063 100644 --- a/plugin/vim-composer.vim +++ b/plugin/vim-composer.vim @@ -58,7 +58,7 @@ endfunction map :call ComposerKnowWhereCurrentFileIs() function! ComposerKnowWhereCurrentFileIs() let l:currentWord = expand('') - let l:command = "grep " . l:currentWord . " vendor/composer -R | awk '{print $6}' | awk -F\\' '{print $2}'" + 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 @@ -66,6 +66,6 @@ function! ComposerKnowWhereCurrentFileIs() let l:openFileCommand = 'tabe ' g:project_path . l:fileName exec l:openFileCommand else - exec "normal \" . expand('') + echo "No unique file found in composer's generated files" endif endfunction From 1347ed84cf9e8b079c063f39adf76f08f7d98a14 Mon Sep 17 00:00:00 2001 From: Simone Gentili Date: Tue, 26 May 2015 07:54:46 +0200 Subject: [PATCH 4/6] Removed mapping avoinding force this mapping key --- plugin/vim-composer.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/vim-composer.vim b/plugin/vim-composer.vim index 6e69063..1fc3d61 100644 --- a/plugin/vim-composer.vim +++ b/plugin/vim-composer.vim @@ -55,7 +55,6 @@ function! s:ComposerInstallFunc(arg) endif endfunction -map :call ComposerKnowWhereCurrentFileIs() function! ComposerKnowWhereCurrentFileIs() let l:currentWord = expand('') let l:command = "grep " . l:currentWord . " ./vendor/composer -R | awk '{print $6}' | awk -F\\' '{print $2}'" From 8c3c1436f0d08387099c1e31b65fd65e5dd176d1 Mon Sep 17 00:00:00 2001 From: Simone Gentili Date: Tue, 26 May 2015 13:48:43 +0200 Subject: [PATCH 5/6] Added readme instruction for ComposerKnowWhereCurrentFileIs function --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 41a62bd..db0d6e4 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,13 @@ 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 :call ComposerKnowWhereCurrentFileIs() + + ## Install ```vim Bundle 'vim-php/vim-composer' From 52f4ff4c5e2956659fc01a7dcabf8cab28299195 Mon Sep 17 00:00:00 2001 From: Simone Gentili Date: Tue, 26 May 2015 16:37:34 +0200 Subject: [PATCH 6/6] Added markdown indentation for suggested remapping --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index db0d6e4..a116a41 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ This command open `composer.json` :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 :call ComposerKnowWhereCurrentFileIs() + + map :call ComposerKnowWhereCurrentFileIs() ## Install