A simplified fork from vim-scripts/AutoComplPop
I'm a PHP developer, and currently I'm using neovim.
- Neocomplete needs
if_lua
, which is not possible with neovim currently. With deoplete framework, currently the only option is phpcomplete-extended. But phpcomplete_extended seems to be unmaintained right now, the latest comment is from two years ago.- YCM is really a great one. But It's just too heavy for me, it significantly slows down my vim's startup time.
- The origional AutoComplPop is a little bit complicated, and hard to extend for me.
- I know I would be re-inventing the wheel but I just couldn't stop it 😂
Finally I decided to create my own SimpleAutoComplPop, focus on easy to use, and easy to be extended for your own use cases. SimpleAutoComplPop maps keys on a per-buffer basis, technically it will not conflict with other auto-complete plugin if you configure carefully.
As a lightweight plugin, the default auto-complete-popup
behavior provideed by this plugin only covers .php
, .txt
,
.markdown
, and .go
files, for demonstration purpose. If you have a good
configuration to share, please send me a gist url or a your github repo url,
I'll add it into this README.md or probably created a wiki page for nice
configurations for other filetypes.
Currently, this is the default php pattern, use omnicomplete's <C-X><C-o>
key
to for completion.
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>"},
\ ]
\ })
Demo with phpcomplete.vim.
Press <TAB>
to select the popup menu.
" 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-o>"} ,
\ { '=~': '\.$' , 'feedkeys': "\<C-x>\<C-o>", "ignoreCompletionMode":1} ,
\ ]
\ })
The special dot character .
needs ignoreCompletionMode
to be set to work
with vim-go, see the
#configiration-options-explained for more
details.
Demo with vim-go
-
To disable SimpleAutoComplPop, 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 vim is still in completion mode (
:help CompleteDone
). However, some plugins does not leave completion mode properly. With current version of vim-go plugin for example, when I typehtt<C-X><C-O>
it will popup a list containinghttp
, then I typehtt<C-X><C-O>p.
. When the.
is typed the popup menu disapears, but the eventCompleteDone
is not triggered. This would cause SACP failed to feed<C-X><C-O>
properly. set theignoreCompletionMode
to1
would fix this issue. -
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. -
inoremap, a list of characters to be
inoremap
ed by SACP to check for matches, default value is[ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_', '~', '^', '.', ',', ':', '!', '#', '=', '%', '$', '@', '<', '>', '/', ', '<Space>', '<C-h>', '<BS>']
. You may change this to add Russian characters, for example.
-