|
| 1 | +phpcomplete-extended |
| 2 | +==================== |
| 3 | + |
| 4 | +phpcomplete-extended is a fast, extensible, context aware autocomplete plugin |
| 5 | +for PHP composer projects. Initially it reads autoload classmap of a composer |
| 6 | +project, parses doc-comments of each class and creates index from them. After |
| 7 | +that it auto updates index as you type thanks to |
| 8 | +[vimproc.vim](https://github.com/Shougo/vimproc.vim) plugin. Besides |
| 9 | +autocomplete this plugin have several code inspection features, |
| 10 | + |
| 11 | +* Includes full core PHP documentation |
| 12 | +* See documentation of current word, be it class name, method or property. It is |
| 13 | + context aware. |
| 14 | +* Go to definition of a symbol. Also context aware. |
| 15 | +* Automatically add use statement of current completed word. Also added plugin |
| 16 | + command of this action. |
| 17 | +* If (Unite) plugin installed following sources are available, |
| 18 | + * `phpcomplete/files` : Lists PHP files of the project. |
| 19 | + * `phpcomplete/vendors` : Lists vendor directories |
| 20 | + * `phpcomplete/extends` : Lists classes that extends the class guessed from |
| 21 | + the current cursor word. |
| 22 | + * `phpcomplete/implements` : Lists classes that implements the class guessed |
| 23 | + from the current cursor word. |
| 24 | + |
| 25 | +Installation |
| 26 | +------------- |
| 27 | + |
| 28 | +The plugin depends on following plugins, |
| 29 | + |
| 30 | +* [vimproc.vim](https://github.com/Shougo/vimproc.vim) : Asynchronous library for vim. Required for auto-update index. C |
| 31 | + compiler is needed to build the plugiin. For windows install cygwin or |
| 32 | + msys to get the compiler. |
| 33 | +* [unite.vim](https://github.com/Shougo/unite.vim/): Optional, but enables some good features. |
| 34 | + |
| 35 | +Plugin managers are recommended for installing these plugins. Installation instructions for |
| 36 | +various plugin managers are given bellow. |
| 37 | + |
| 38 | +## Pathogen |
| 39 | + |
| 40 | +Issue following commands. |
| 41 | + |
| 42 | +```sh |
| 43 | +git clone https://github.com/Shougo/vimproc.vim.git ~/.vim/bundle |
| 44 | +cd ~/.vim/bundle/vimproc.vim |
| 45 | +make |
| 46 | +cd .. |
| 47 | +git clone https://github.com/Shougo/unite.vim.git ~/.vim/bundle |
| 48 | +git clone https://github.com/m2mdas/phpcomplete-extended.git ~/.vim/bundle |
| 49 | +``` |
| 50 | + |
| 51 | +## NeoBundle (prefered) |
| 52 | +Put these lines in `.vimrc` and issue `source %` command |
| 53 | + |
| 54 | +```vim |
| 55 | +NeoBundle 'Shougo/vimproc', { |
| 56 | + \ 'build' : { |
| 57 | + \ 'windows' : 'make -f make_mingw32.mak', |
| 58 | + \ 'cygwin' : 'make -f make_cygwin.mak', |
| 59 | + \ 'mac' : 'make -f make_mac.mak', |
| 60 | + \ 'unix' : 'make -f make_unix.mak', |
| 61 | + \ }, |
| 62 | + \ } |
| 63 | +NeoBundle 'Shougo/unite.vim' |
| 64 | +NeoBundle 'm2mdas/phpcomplete-extended' |
| 65 | +"your other plugins |
| 66 | +NeoBundleCheck |
| 67 | +``` |
| 68 | + |
| 69 | +If C compiler found for respective environment, `neobundle` will automatically |
| 70 | +compile the library. |
| 71 | + |
| 72 | +## Vundle |
| 73 | + |
| 74 | +Put following lines in `.vimrc` and issue `:BundleInstall` command. |
| 75 | +```vim |
| 76 | +Bundle 'Shougo/vimproc' |
| 77 | +Bundle 'Shougo/unite.vim' |
| 78 | +Bundle 'm2mdas/phpcomplete-extended' |
| 79 | +"your other plugins |
| 80 | +".... |
| 81 | +``` |
| 82 | + |
| 83 | +After installation goto `vimproc` folder and issue `make` command from command |
| 84 | +line. C compiler must be installed. |
| 85 | + |
| 86 | +Walk through of the plugin |
| 87 | +------------------------- |
| 88 | + |
| 89 | +To enable omni complete add following line to `.vimrc`, |
| 90 | + |
| 91 | + autocmd FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP |
| 92 | + |
| 93 | +Then issuing `<C-X><C-O>` in insert mode will open the completion pop-up menu. |
| 94 | + |
| 95 | +This plugin is tested in Windows and Linux. It should work in OSX also. |
| 96 | + |
| 97 | +For now this plugin supports [Composer](http://getcomposer.org/) PHP projects. |
| 98 | +Upon detecting a composer project the plugin scans classmap generated by `php |
| 99 | +composer.phar dumpautoload --optimize` command. By default composer command is |
| 100 | +set to `php composer.phar`. The command can be changed by setting |
| 101 | +`g:phpcomplete_index_composer_command` global variable. |
| 102 | + |
| 103 | +The plugin is dependent on `@var`, `@param`, `@return` doc-comments to give proper context aware |
| 104 | +autocomplete. So documenting your class will help tremendously. It does not |
| 105 | +analyse full class. Just parses the variable declaration to get the relevant |
| 106 | +tokens. Does not provide autocomplete suggestion if there is error in code. |
| 107 | + |
| 108 | +Indexing may take some time depending on project size. To decrease index creation time I |
| 109 | +would recommend disabling xdebug extension in cli. To do that go to the location |
| 110 | +where `php.ini` resides and copy the `php.ini` file as `php-cli.ini` and comment |
| 111 | +out the xdebug line. To verify issue `php -m | grep xdebug` in commandline. |
| 112 | + |
| 113 | +For configuration reference see helpdoc. |
| 114 | + |
| 115 | + |
| 116 | +Auto complete plugin supports |
| 117 | +----------------------------- |
| 118 | + |
| 119 | +## [neocomplete](https://github.com/Shougo/neocomplete.vim) |
| 120 | + |
| 121 | +Neocomplete support is built-in and my preferred autocomplete plugin. It needs |
| 122 | +vim with lua bindings. To know more about installation refer to the plugin |
| 123 | +repository. |
| 124 | + |
| 125 | +## [YouCompleteMe](https://github.com/Valloric/YouCompleteMe) |
| 126 | + |
| 127 | +If `omnifunc` set the omni completer of `YouCompleteMe` should get the completion |
| 128 | +candidates. I haven't tested it though. |
| 129 | + |
| 130 | +Extensions |
| 131 | +--------- |
| 132 | + |
| 133 | +Phpcomplete Extended pluign exposes api hooks so that it can be possible to |
| 134 | +provide framework specific autocomplete suggestion. For example facades in |
| 135 | +laravel, DIC services in Symfony2 etc. The plugin api divided in two part, `PHP` |
| 136 | +and `vim`. PHP part is responsible for creating index related to the framework, |
| 137 | +and vim part is responsible for providing autocomplete menu entries based on the |
| 138 | +index. For reference see |
| 139 | +[phpcomplete-extended-symfony](https://github.com/m2mdas/phpcomplete-extended-symfony) |
| 140 | +and |
| 141 | +[phpcomplete-extended-laravlel](https://github.com/m2mdas/phpcomplete-extended-laravlel) plugins. |
| 142 | + |
| 143 | +License |
| 144 | +------- |
| 145 | +MIT licensed. |
| 146 | + |
| 147 | +Acknowledgement |
| 148 | +--------------- |
| 149 | + |
| 150 | +This plugin would not be possible without the works of |
| 151 | +[Shougo](https://github.com/Shougo), |
| 152 | +[shawncplus](https://github.com/shawncplus/), |
| 153 | +[tpope](https://github.com/tpope/), [vim-jp](https://github.com/vim-jp), |
| 154 | +[thinca](https://github.com/thinca) and many others. |
| 155 | + |
0 commit comments