Omnicompletion stops giving useful predictions

I am trying to install omni completion for PHP in vim 7.3 with ctags 5.9 ~ svn20110310 on Ubuntu 12.04.1 (LTS), but I ran into a very strange problem when the completion provides radically different predictions for instances of the same class.

I have the following two files:

// Foo.php class Foo { public function do_stuff() { echo 'Working...'; } } // index.php require 'Foo.php'; $f = new Foo(); $f->[cursor position 1] $g = new Foo(); $g->[cursor position 2] 

When the cursor is at position 1 and I press CTRL + X CTRL + O , it compiles the line with do_stuff( as expected. But when I press CTRL + X CTRL + O in the second position, I get a list of predictions starting with key, next, rewind What am I doing wrong?

+7
source share
1 answer

Edit: Regarding a specific problem, if you have an old version of phpcomplete.vim, it is possible that you can only complete the variable correctly by marking it with the special phpdoc tag ( see this question ) or by regenerating the tag file after declaring the variable.

In all likelihood, you are not doing anything wrong; PHP support in ctags is extremely simple and not very strict, which, unfortunately, also means lack of Vim support. A quick look at the ctags module illustrates the problem:

ctags / php.c

What is it. Just a few basic regular expressions. This parser material below is not used anywhere, and tragically was not very long.

The combination of the problem is that the standard omnicomplete function for PHP in Vim is hacker at best; suffice it to say that it includes a transition between all open windows as part of the process of its completion (a practice clearly condemned by the Vim documentation). See for yourself:

phpcomplete.vim / autoload / phpcomplete.vim

For a long time I struggled with the terrible termination of PHP in Vim and decided that nothing but a complete revision would bring a satisfactory result. I joined the ctags dev mailing list and I plan to improve PHP support there before moving on to making Vim omnicompletion work as much as possible in an interpreted language. At the moment, unfortunately, the solution is to wait until the support is better, or fix it yourself.

+4
source

All Articles