SyntaxComplete


Ⅰ. 插件描述

OMNI Completion based on the current syntax highlights

Ⅱ. 基本信息

创建日期:  2010-07-29
使用用户:  56
Github星:  36
插件作者:  David Fishburn

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

SyntaxComplete.vim is a plugin which uses the new Vim7 OMNI completion features (intellisense code completion).

SyntaxComplete.vim version 5.0 is included in the Vim 7.2 release.
SyntaxComplete.vim version 7.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 8.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 9.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 10.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 11.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 12.0 is included in the Vim 7.3 release.
SyntaxComplete.vim version 13.0 is included in the Vim 7.3 release.

What does it do:

Vim has the ability to color syntax highlight nearly 500 languages.  Part of this highlighting includes knowing what keywords are part of a language.  Many filetypes already have custom completion scripts written for them, the syntaxcomplete plugin provides basic completion for all other filetypes.  It does this by populating the omni completion list with the text Vim already knows how to color highlight.  It can be used for any filetype and provides a minimal language-sensitive completion.

There are not many languages with full blown OMNI completion scripts written in Vim.  Yet, having a list of functions and keywords to complete can be very handy especially when you are working with a predefined API.

Adding the following to your .vimrc, will setup SyntaxComplete for every filetype that does not already have a language specific OMNI script:

    if has("autocmd") && exists("+omnifunc")

autocmd Filetype *
        \    if &omnifunc == "" |
        \        setlocal omnifunc=syntaxcomplete#Complete |
        \    endif

    endif

It also provides some public functions so other plugin writers can pull syntax keywords (based on group names) from Vim and utilize them in any manor.  Examples are included in the help files, but here is a simple example:
    let myKeywords = []
    let myKeywords = OmniSyntaxList( ['sqlKeyword'] )
    let allItems = OmniSyntaxList( [] )

Regex can also be used to identify which syntax groups to include:
    let myKeywords = OmniSyntaxList( ['htmlw+', 'jqueryw+'] )

Existing instructions can be found within Vim7 using
:h ft-syntax-omni

This plugin is new to Vim7.  Improvements to the script will be uploaded here, and supplied to Bram for inclusion into future versions of Vim7.

There are many customizations which can be made per filetype via your .vimrc.  See the documentation for details.

添加新评论