Vim PHP omni completion

前端 未结 9 1067
醉话见心
醉话见心 2020-12-07 12:44

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 omn

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 12:52

    The following works better. Taken from http://weierophinney.net/matthew/archives/134-exuberant-ctags-with-PHP-in-Vim.html

    ctags \
    -f ~/.vim/tags \
    -h ".php" -R \
    --exclude="\.svn" \
    --totals=yes \
    --tag-relative=yes \
    --PHP-kinds=+ivcf \
    --regex-PHP='/(abstract)?\s+class\s+([^ ]+)/\2/c/' \
    --regex-PHP='/(static|abstract|public|protected|private)\s+function\s+(\&\s+)?([^ (]+)/\3/f/' \
    --regex-PHP='/interface\s+([^ ]+)/\1/i/' \
    --regex-PHP='/\$([a-zA-Z_][a-zA-Z0-9_]*)/\1/v/' \
    

    Even with the above, there seems to be some issues. e.g. phpcomplete doesn't seem to support methods of instance vars.

    $this->objA = new SomeClass();
    $this->objA-> #fails
    

    However,

    $objA = new SomeClass();
    $objA-> #works
    

    After trying to get phpcomplete working for the last few hours my advice to anyone also trying, is to STOP. It doesn't work well and is not worth the trouble.

提交回复
热议问题