Vim的PHP全完成 [英] Vim PHP omni completion

查看:88
本文介绍了Vim的PHP全完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让PHP自动完成正确的Vim中。现在,当我做了 $ =博客新的博客(); $ blog-> ,然后点击 CTRL + X CTRL + O 我期望omnicompletion返回类中的所有功能博客

相反,它返回为整个项目的所有功能。我已经建立的ctags为我的项目,像这样:的ctags -R *

有没有什么办法让自动完成上下文感知?


解决方案

<一个href=\"http://stackoverflow.com/questions/1224838/vim-php-omni-completion/2316468#2316468\">catchmeifyoutry's回答通过添加注释,如 / * @var $ myVar的myClass的* / 紧接使用omnicomplete前行,然而指出一个变通这是繁琐和花费写评论的时候,你可能也有自己写的函数名。

解决方案:phpComplete

这是一个Vim脚本: phpComplete

您还需要为你的类生成一个标记文件,但你可以使用文件中的全方位完整的,像这样(从脚本的页面上的说明修改);


  

本补丁允许在文件检查,所以你不需要评论。

  $ =博客新的博客;
...
$ blog-&GT;布拉赫(); //&LT; - 完全不加评论


  
  

它还允许支持单实例:

  $例如= ::类的getInstance();
$实例 - &GT; completeMe(); //甜蜜完成


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 Blog.

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.

Solution: phpComplete

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

这篇关于Vim的PHP全完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆