I'm trying to get PHP autocompletion right in Vim. Right now when I do a
$blog = new Blog(); $blog-> and then hit
CTRL+X CTRL+O I'd expect omnicompletion to return all the functions in the class
Instead, it returns all functions for the entire project. I've built ctags for my project like so:
ctags -R *
Is there any way to make the autocompletion context-aware?
catchmeifyoutry's answer points out a work-around by adding a comment such as
/* @var $myVar myClass */ immediately before the line on which you use omnicomplete, however this is cumbersome and for the time it takes to write the comment, you may as well have written the function name yourself.
It is a Vim script: phpComplete
You will still need a tags file generated for your classes, but you can then use omni complete within the file, like so (modified from the description on the script's page);
This patch allows for in-file checking so you don't need the comment.
$blog = new Blog; ... $blog->Blah(); // <-- complete without comment
It also allows support for singleton instantiations:
$instance = Class::getInstance(); $instance->completeMe(); // sweet completion