simpleautocomplpop


Ⅰ. 插件描述

Please use https://github.com/ncm2/ncm2 instead

Ⅱ. 基本信息

创建日期:  2016-07-04
使用用户:  12
Github星:  22
插件作者:  rox

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# SimpleAutoComplPop

**Note: I'm not mantaining this plugin anymore, in favor of
nvim-completion-manager.
If you have plans for improving this plugin by yourself, please contact me, I'll
transfer the project ownership.**

A simplified fork from vim-scripts/AutoComplPop

SimpleAutoComplPop is a lightweight, pure vimscript plugin, which
focuses on easy to use, and easy to be extended for your own use cases.
SACP maps keys on a per-buffer basis. Technically it will not conflict with
other auto-complete plugin if you configure carefully.

Usage

Currently, SACP only provides default configurations for php, go, txt and
markdown files.

PHP

    autocmd FileType php,php5,php7 call sacp#enableForThisBuffer({ "matches": [
                \ { '=~': '\v[a-zA-Z]{4}$', 'feedkeys': "\<C-x>\<C-o>"},
                \ { '=~': '::$'           , 'feedkeys': "\<C-x>\<C-o>"},
                \ { '=~': '->$'           , 'feedkeys': "\<C-x>\<C-o>"},
                \ ]
                \ })

This demo requires phpcomplete.vim.

php_demo

Golang

    " 1. variables are all defined in current scope, use keyword from current
    " buffer for completion `<C-x><C-n>`
    " 2. When the '.' is pressed, use smarter omnicomplete `<C-x><C-o>`, this
    " works well with the vim-go plugin
    autocmd FileType go call sacp#enableForThisBuffer({ "matches": [
                \ { '=~': '\v[a-zA-Z]{4}$' , 'feedkeys': "\<C-x>\<C-n>"} ,
                \ { '=~': '\.$'            , 'feedkeys': "\<C-x>\<C-o>", "ignoreCompletionMode":1} ,
                \ ]
                \ })

This demo requires vim-go.

go_demo

Seems good. While SACP provides **a slightly improved
plugin key
<Plug>(sacp_cache_fuzzy_omnicomplete)**.
Check the Advanced Features section For more details.

Configiration Options Explained

  • To disable SACP, add let g:sacpEnable = 0 to your vimrc file.
  • To enable the default auto-complete-popup behavior for php only, add `let
    g:sacpDefaultFileTypesEnable = {"php":1}` to your vimrc file.
  • sacp#enableForThisBuffer options:

    • matches is a list of patterns, pattern is matched, the keys
      corrosponding the pattern will be feed to vim.

      • ignoreCompletionMode. By default, Keys will not be feeded by SACP
        if popup enu is visible or vim is still in completion mode (`:help
        CompleteDone`). However, It's difficult for complete-functions to
        leave completion mode properly. With current version of
        vim-go plugin for example, when
        I type htt<C-X><C-O> it will popup a list containing http, then
        I proceed the typing to htt<C-X><C-O>p.. When the . is typed
        the popup menu is gone, but the event CompleteDone event is not

        1. Set the ignoreCompletionMode to 1 would force
          SACP to feed the <C-X><C-O> keys..
    • completeopt, the default value for this option is
      "menu,menuone,noinsert,noselect", set it to "menu,menuone,noinsert"
      if you want the first hint to be selected by default.

Advanced Features

<Plug>(sacp_cache_fuzzy_omnicomplete)

Use the golang example before, I'll change the \<C-x>\<C-o> into
\<Plug>(sacp_cache_fuzzy_omnicomplete). This key is based on user's default
omnifunc, it catches the first list return by omnifunc, then provide fuzzy
completion feature.

    " 1. variables are all defined in current scope, use keyword from current
    " buffer for completion `<C-x><C-n>`
    " 2. When the '.' is pressed, use smarter omnicomplete `<C-x><C-o>`, this
    " works well with the vim-go plugin
    autocmd FileType go call sacp#enableForThisBuffer({ "matches": [
                \ { '=~': '\v[a-zA-Z]{2}$' , 'feedkeys': "\<C-x>\<C-n>"} ,
                \ { '=~': '\.$'            , 'feedkeys': "\<Plug>(sacp_cache_fuzzy_omnicomplete)", "ignoreCompletionMode":1} ,
                \ ]
                \ })

Type http.ok, then there goes the first hint StatusOk

go_demo

<Plug>(sacp_cache_fuzzy_bufferkeyword_complete)

Use the keywords (:help iskeyword) from current buffer for fuzzy completion.
It only scans the keywords from the 50 lines before and after the current line,
for performance issue. Use the golang example, replace the "\<C-x>\<C-n>"
with "\<Plug>(sacp_cache_fuzzy_bufferkeyword_complete)" and see what happens.

添加新评论