Jun 25, 2010

My neocomplcache setting

As requested, here is my .vimrc setting for neocomplcache.
Beware that the following setting works only for "ver.5" branch.
You have to check it out from github.


" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Use camel case completion.
let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
let g:neocomplcache_enable_underbar_completion = 1

let g:neocomplcache_auto_completion_start_length = 3
let g:neocomplcache_manual_completion_start_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'

" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
    let g:neocomplcache_keyword_patterns = {}
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'

" snippets expand key
imap  <silent><expr><TAB>  neocomplcache#plugin#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : (pumvisible() ? "\<C-e>" : "\<TAB>")
"imap  <silent><expr><TAB>  neocomplcache#plugin#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : "\<C-e>"
smap  <TAB>  <RIGHT><Plug>(neocomplcache_snippets_jump)
inoremap <expr><C-e>     neocomplcache#complete_common_string()

Jun 17, 2010

SuperTab complete for neocomplcache

As I said in my previous post, neocomplcache is a very powerful vim plugin.
It incoporates the funtionality of SnipMate and  AutoComplPop while providing efficient search
for potential completion items.

However, SuperTab does not support neocomplcache. It is very bad since I like to tab complete
everything, including snippets. Here is the solution -- put the following in you .vimrc:

imap  <silent><expr><tab>  neocomplcache#sources#snippets_complete#expandable() ? "\<plug>(neocomplcache_snippets_expand)" : (pumvisible() ? "\<c-e>" : "\<tab>")
smap  <tab>  <right><plug>(neocomplcache_snippets_jump) 
inoremap <expr><c-e>     neocomplcache#complete_common_string()

The above setting allows you to trigger a snippet with "tab" key when possible. If not, it will simply trigger omni completion. I set it to complete the longest common string. It is just a personal taste. You can set it to other type of completion as well.

*Update 2010/12/11 for necomplcache V5.2 compatiblity
*Update 2012/04/24 for necomplcache V7 compatiblity