sponsor Vim development Vim logo Vim Book Ad

phpcomplete.vim : php omnicomplete with extra support

 script karma  Rating 79/26, Downloaded by 4185    Comments, bugs, improvements  Vim wiki

created by
Shawn Biddle
 
script type
ftplugin
 
description
Default phpcomplete.vim does not support in-file checking of $var = new Class; so if you don't have a tags file with the variable in it already you have to hack around it by placing the comment /* @var $yourvar YourClass */ above the line which is really kludgy.

This patch allows for in-file checking so you don't need the comment.

$instance = new Class;
...
$instance->Blah(); // <-- complete without comment

It also allows support for singleton instantiations:

$instance = Class::getInstance();
$instance->completeMe(); // sweet completion

=== Usage ===
// example class which has a TAGS file generated for it somewhere
class SomeClass {
  private function _private_method() {} // never shows up in completion list
  public static function staticMethod() {} // only shows up when using completion on SomeClass::<C-X><C-O>
  public function completeMe() {} // only shows up when using completion on $instance_of_someclass-><C-X><C-O>
}

== Non-static completion ==
$instance = new SomeClass;
...
$instance-><C-X><C-O> to display the omnicompletion menu (see :help ins-completion)
$instance->completeMe(); // will autoselect completeMe since it's the only public non-static method

== Static completion ==
SomeClass::<C-X><C-O> to display omnicompletion menu
SomeClass::staticMethod(); // once again will autoselect staticMethod since it's the only public static method

== Singleton completion ==
$instance = SomeClass::getInstance();
$instance-><C-X><C-O> complete just like non-static



=== Other features ===
* Correct restriction of static or standard methods based on context ( show only static methods with :: and only standard with ->)
* Real support for self:: and $this-> with the aforementioned context restriction
* Constant variable completion (not just define(VARIABLE, 1) but const VARIABLE = 1)

Follow updates:
http://github.com/shawncplus/phpcomplete.vim
 
install details
Place in $HOME/.vim/autoload/phpcomplete.vim and enable the php ftplugin
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
phpcomplete.vim 1.3.3 2010-10-26 7.0 Shawn Biddle Also do in-file checking for static completion
phpcomplete.vim 1.3.2 2010-08-05 7.0 Shawn Biddle Don't complete self::, static::, or $this-> while outside of a class
phpcomplete.vim 1.3.1 2010-08-05 7.0 Shawn Biddle Support for PHP 5.3's LSB static:: context
phpcomplete.vim 1.3 2010-07-29 7.0 Shawn Biddle Correctly limit completion lists to static or normal methods based on :: or ->. Adds support for self:: completion
phpcomplete.vim 1.2 2010-07-29 7.0 Shawn Biddle Added in-file completion for $this-> context
phpcomplete.vim 1.1 2010-07-28 7.0 Shawn Biddle Added support for completion of const variables (const SOMETHING = 1;, not just
define("SOMETHING", 1);)
phpcomplete.vim 1 2010-07-28 7.2 Shawn Biddle Initial upload
ip used for rating: 54.237.235.12

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo