Php autocomplete with vim

I am looking for a php autocomplete solution for vim. I have already been in this thread: Implementing Vim PHP omni, but this does not work for me. I am creating a tag file using this bash script:

#!/bin/bash exec ctags -V -f tags \ -h \".php\" -R \ --exclude=\"\.git\" \ --totals=yes \ --language-force=PHP \ --tag-relative=yes \ --PHP-kinds=+cfiv \ --regex-PHP='/(abstract)?\s+class\s+([^ ]+)/\2/c/' \ --regex-PHP='/(static|abstract|public|protected|private)\s+(final\s+)?function\s+(\&\s+)?([^ (]+)/\4/f/' \ --regex-PHP='/interface\s+([^ ]+)/\1/i/' \ --regex-PHP='/\$([a-zA-Z_][a-zA-Z0-9_]*)/\1/v/' \ kernel/classes/ 

but autocomplete does not match what you want. I don’t even know if the plugin is loading. so how can i see the plugin loading? (the plugin is under the beam, I use the pathogen, and other plugins work). need to activate something else? I have VIM-Vi IMproved 7.3, Exuberant Ctags 5.8

thanks

+4
source share
4 answers

I also tried to improve php autocomplete work in vim. I used the phpcomplete.vim plugin, but found out that an error occurred while using multiple tag files (which is not unusual in most vimrc configurations). In this case, it simply searches for the first tag file to resolve the class file name, and then returns to standard completion (showing a long long list containing no scope)

However, I forked the plugin and fixed the error. For me, this works great now: https://github.com/sebastiankessler/phpcomplete.vim

+4
source

If your projects are a composer project then check out my phpcomplete-extended plugin. For the Symfony2 site, Laravel projects also check phpcomplete-extended-symfony and phpcomplete-extended-laravel plugins, respectively.

+3
source

What will be the desired effect? What do you expect? What are you getting? Vim does not have an “autocomplete” function: its own completion brand is called “omni completion” and is not automatic at all.

I have been using the phpComplete script linked in one of the other questions, combined with ctags without any problems for quite some time. In fact, I wrote the following examples, thinking that I was using it, but I forgot that a few weeks ago I deleted a bunch of scripts and plugins, including phpComplete.vim .

So the following works very well with Vim 7.3 / Exuberant Ctags 5.8 stock.

From a.php :

 <?php class MyClass { public function MyClass(argument) { echo 'Hello.'; } private function secret() { echo 'Shhhh…'; } public function say() { echo 'what?'; } } ?> 

and cursor as specified in b.php

 <?php include 'a.php'; $example = new MyClass(); $example->| //cursor here ?> 

<Cx><Co> gives me the following options:

 say( f MyClass( f 

I don't get a list of built-in functions a mile long, and I don't even get private methods.

0
source

Padawan with Deoplete are great solutions for providing reliable PHP completion in Neovim. For Vim, you can use Neocomplete instead of Deoplete.

I wrote an article on how to make a Vim PHP IDE if anyone is interested :)

0
source

All Articles