vim-customcpt


Ⅰ. 插件描述

Easily create custom completion menus using any json or tab-separated file

Ⅱ. 基本信息

创建日期:  2017-01-04
使用用户:  1
Github星:  14
插件作者:  Jay Sitter

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/jsit/vim-customcpt

Ⅳ. 文档说明

# vim-customcpt

Easily create custom completion menus using any dictionary/json file, in the format:

{ "word(" : { "kind" : "f", "menu" : "menu", "info" : "info" } }

Or a tab-separated values file, like this:

word kind menu info

So, for instance, a WordPress function (a full example wordpress.json file is included in this repo):

{
  "get_bloginfo(" : {
    "kind" : "f",
    "menu" : "string $show, string $filter | string",
    "info" : "Retrieves information about the current site.",
  }
}

Or, as tab-separated values:

get_bloginfo( f string $show, string $filter | string Retrieves information about the current site.

See :help complete-items for more info:

word        the text that will be inserted, mandatory
kind        single letter indicating the type of completion
menu        extra text for the popup menu, displayed after "word"
            or "abbr"
info        more information about the item, can be displayed in a
            preview window

Your custom completion file will show up as a "full" complete menu similar to the omnicomplete menu, like so:

Options

By itself, this plugin does nothing. Only by setting a couple dictionaries in your .vimrc will <C-X><C-U> use the completion function generated by your file.

g:customcpt_funcs (required): A Dictionary with a function name for a key and a List of files to use for completion with it

let g:customcpt_funcs = {
        \ "WPComplete" : [
            \ $HOME . "/.vim/wordpress.json",
        \ ]
    \ }
endif

g:customcpt_types (optional): A Dictionary with a comma-separated list of filetypes as keys and the name of a completion function to use with them

let g:customcpt_types =  {
        \ "php,php.html" : "WPComplete",
    \ }
endif

Alternatively, you could just do something like this in your .vimrc:

au FileType php,php.html setlocal completefunc=WPComplete

Thanks

This plugin is heavily based on @aaronspring’s cdo_lazy_vim plugin. Thanks Aaron! 👋

Thanks also to Steve Losh’s Learn Vimscript the Hard Way and the Stack Exchange community.


Related: CompleteHelper

添加新评论