Ⅰ. 插件描述
Plugin which decides which type of insert completion to use based on contextⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/contextcomplete'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/contextcomplete'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/contextcomplete'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/contextcomplete
Ⅳ. 文档说明
INTRODUCTION
contextcomplete is a plugin that decides what kind of |ins-completion| to use
based on the text that is before the cursor. This is triggered by the key
specified in "g:contextcomplete_trigger". This key is also mapped
to cycle through all the possible options until the completion menu is
exited. Regexes are used to determine which type of completion is used, which
can be configured using the "g:contextcomplete_detect_regexes" dictionary.
A table of possible keys for this dictionary and the related completion type
can be found at "g:contextcomplete_detect_regexes".
CUSTOMIZATION
contextcomplete can be customized to use user defined regexes to detect what
kind of completion to use. The first completion type specified in
"g:contextcomplete_key_order" whose associated regex matches is the
completion type that is used. If "g:contextcomplete_detect_regexes".ignore is
specified, it will always override any of the other completion types and make
"g:contextcomplete_trigger" behave as it normally would in insert mode. The
same happens if none of the specified regexes match. A table for the possible
keys in "g:contextcomplete_detect_regexes" is available below.
Dictionary Key Related Keystroke Default Value
lines i_CTRL-X_CTRL-L None
keywords i_CTRL-X_CTRL-N 'vw{-1,}$'
dictionary i_CTRL-X_CTRL-K None
thesaurus i_CTRL-X_CTRL-T None
keywords-included i_CTRL-X_CTRL-I None
tags i_CTRL-X_CTRL-] None
file-names i_CTRL-X_CTRL-F 'v/(w|-){-}$'
macros i_CTRL-X_CTRL-D None
cmdline i_CTRL-X_CTRL-V None
user i_CTRL-X_CTRL-U None
omnicomplete i_CTRL-X_CTRL-O 'v.w{-}$'
spelling i_CTRL-X_s None
complete-keywords i_CTRL-N None
ignore None 'v^s*$'
You can find help for what kind of completion each related keystroke does by
looking it up in vim's help. For omnicomplete, you would do:
:help i_CTRL-X_CTRL-O
The default configuration of this dictionary will use keyword completion
before a word, file name completion before a forward slash, and omnicompletion
before a dot.
Example of a configuration for detection regexes:
let g:contextcomplete_detect_regexes = {
'keywords': 'v<w+>$', 'ignore': '\v^\s*$'
}
You can specify which completion types have precedence over each other using
this list. By default, the order is: file-names, omnicomplete, keywords.
If any of the possible completion types are left out, their corresponding
completion types in "g:contextcomplete_detect_regexes" will be ignored.
Ignore will always takes precedence over any completion types in this list.
Example:
let g:contextcomplete_key_order = [
'lines', 'keywords', 'dictionary', 'thesaurus', 'keywords-included',
'tags', 'file-names', 'macros', 'cmdline', 'user', 'omnicomplete',
'spelling', 'complete-keywords'
]
You can also specify which key is used to trigger contextcomplete. This key
is also temporarily mapped to cycle throught all the completion options until
the completion menu is exited. The default value for this option is '<Tab>'.
You must use a literal string to specify this key, which can be done by
enclosing the value in single quotes. If you do use a special key like
Tab>, you must escape it like in the example below.
Example:
let g:contextcomplete_trigger = '<Tab>'
ISSUES/DEVELOPMENT
Issues can be reported at the github issue tracker or they can be sent to my
email at <evergreenubuntu[AT]gmail[DOT]com>. The github issue tracker is at
https://github.com/4Evergreen4/vim-contextcomplete/issues. You can also get
the development versions of contextcomplete at https://github.com/4Evergreen4/vim-contextcomplete/
CREDITS
Thank you to bairu for helping me write and debug this plugin.