问题
i'm looking for an php autocomplete solution for vim. I already was at this thread: Vim PHP omni completion but it doesn't work for me. I generate the tags file with 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 the autocomplete is not as desired. I don't even know if the plugin is loading. so, how can i see if the plugin is loading? (the plugin is located under bundle, i use pathogen, and other plugins do work..) it is necessary to activate something else? i have VIM - Vi IMproved 7.3, Exuberant Ctags 5.8
thanks
回答1:
I´ve also tried to get php autocompletion working better in vim. I used the phpcomplete.vim plugin, but found out that there was a bug when using more than one tag file (what is not unusual in most vimrc configs). In this case it just searches the first tagfile to resolve the class-filename, and then fallbacks to the standard completion (showing a long long not scope aware list)
However, i´ve forked the plugin and fixed the bug. For me it´s working wonderful now: https://github.com/sebastiankessler/phpcomplete.vim
回答2:
If your projects is a composer project then checkout my phpcomplete-extended plugin. For Symfony2 land Laravel projects also checkout phpcomplete-extended-symfony and phpcomplete-extended-laravel plugins respectively.
回答3:
What would be the desired effect? What do you expect? What do you get? Vim has no "autocomplete" feature: its own brand of completion is called "omni completion" and is not automatic at all.
I've been using the phpComplete script linked in one of the other question's answers in conjunction with ctags without problems for quite some time. In fact I wrote the following examples thinking I was using it but I forgot I've removed a bunch of scripts and plugins some weeks ago, including phpComplete.vim.
So the following works very nicely with stock Vim 7.3/Exuberant Ctags 5.8.
With a.php:
<?php
class MyClass {
public function MyClass(argument) {
echo 'Hello.';
}
private function secret() {
echo 'Shhhh…';
}
public function say() {
echo 'what?';
}
}
?>
and the cursor as indicated in b.php
<?php
include 'a.php';
$example = new MyClass();
$example->| //cursor here
?>
<C-x><C-o> gives me these choices:
say( f
MyClass( f
I don't get a mile-long list of builtin functions and I don't even get private methods.
回答4:
Padawan with Deoplete are great solutions for having a robust PHP autocompletion in Neovim. For Vim you can use Neocomplete instead of Deoplete.
I wrote an article how to make a Vim PHP IDE if somebody is interested :)
来源:https://stackoverflow.com/questions/9863706/php-autocomplete-with-vim