php annotations syntax


Ⅰ. 插件描述

syntax highlighting for php annotations

Ⅱ. 基本信息

创建日期:  2013-04-29
使用用户:  3
Github星:  1
插件作者:  Timothy Madden

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin '/php-annotations-syntax'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle '/php-annotations-syntax'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug '/php-annotations-syntax'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/vim-scripts/php-annotations-syntax

Ⅳ. 文档说明

Small script to add  annotations highlighting to php syntax.

Annotations within comments are highlighted with pre-defined SpecialComment highlight group name (used for example for backslash escapes in string literals).

Annotations highlighting is useful when they are used as more then documentation blocks or comments, like for actual program flow control, as doctrine ORM is using them. Some people might consider such use of comments, as part of the program logic, to be bad practice, and the script author here tends to agree. But this is how annotation syntax works in php, so this is how they  are used anyway. Doctrine ORM tends to look for annotations anywhere within a comment line, but only annotations that start at the beginning of a comment line will be highlighted here.

php annotations use docBlock comments (documentation comment blocks, beginning with /* and ending with /) and the main use case for this syntax script is to contrast the regular annotations with any of them accidentally placed within simple comments, where they have no effect, so you can spot them easier.

If you find the highlighting annoying with your color scheme or with your annotations usage in php, you may use a command like
     :highlight link SpecialComment Number
to change the appearance (you can replace Number above with some other highlight group you may like), or you can disable the script with the
     :let g:php_annotations_syntax = 0
command in your .vimrc file.

If and when the main php syntax file provided with Vim ever gets updated to include annotations, this script will become obsolete.

That main file is getting quite old with all new php functions and classes added by every new php version; currently there are several newer alternatives on the Vim scripts site, but they like to replace, instead of extend, the main file provided by the distribution.

添加新评论