Ⅰ. 插件描述
Insert namespace for current fileⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'dantleech/vim-phpnamespace'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'dantleech/vim-phpnamespace'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'dantleech/vim-phpnamespace'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/dantleech/vim-phpnamespace
Ⅳ. 文档说明
Vim Namespace
Plugin which guesses the namespace of the current file from composer.json.
Note that the algorithm for determining the namespace is not 100% accurate
(although it could be) but it should work in the majority of cases.
It should work with both psr-0 and psr-4 projects.
Installation
With Vundle:
Plugin "dantleech/vim-phpnamespace"Usage
Map it:
nnoremap <silent><leader>nn :call PhpNamespaceInsert()<CR>Call it:
let s:foo = PhpNamespaceGet()Integration with Ultisnips
Use it with ultisnips to generate class / interface templates:
snippet interface "Interface declaration template" !b
<?php
namespace ${1:`!v PhpNamespaceGet()`};
interface ${1:`!v expand("%:t:r")`}
{
$0;
}
endsnippet
snippet class "Class declaration template" !b
<?php
namespace ${1:`!v PhpNamespaceGet()`};
class ${1:`!v expand("%:t:r")`}
{
$0;
}
endsnippet