4

I am trying to get vim setup such that when I edit a C or C++ file it uses the YouCompleteMe plugin for completions, and for everything else it uses NeoComplCache.

I'm starting with v3.0 of the spf13 vim configuration.

I've added the following to my .vimrc.bundles.local:

Bundle 'Valloric/YouCompleteMe'

I've added the following to my .vimrc.local:

let g:ycm_filetype_whitelist = { 'c': 1, 'cpp': 1 }
let g:neocomplcache_force_overwrite_completefunc = 0

This appears to disable YouCompleteMe for everything except C/C++, however I'm not sure how to disable NeoComplCache based on filetype. I have tried:

autocmd FileType c,cpp :NeoComplCacheDisable

However, it appears that NeoComplCache isn't really enabled until you do something in the buffer. What kind of configuration is needed to disable NeoComplCache when I open a C or C++ file in vim?

alanxz
  • 1,966
  • 15
  • 17
  • What about `let g:neocomplcache_disable_auto_complete = 1`? – romainl Mar 25 '13 at 07:48
  • @romainl doesn't work. `completefunc=neocomplcache#manual_complete` after the first insert operation. – alanxz Mar 25 '13 at 16:00
  • Now I remember why I decided to not use that plugin. – romainl Mar 25 '13 at 16:08
  • @alanxz: could you please post your final solution? – BenC Apr 08 '13 at 11:14
  • @BenC: terryma's solution didn't work because :NeoComplCacheLock doesn't restore the omnifunc and complfunc correctly. The solution I thought I had was to have this function call :NeoComplCacheDisable, but due to NCC's lazy initialization (it initializes on CursorHold and CursorHoldI) this doesn't work because NCC isn't enabled at that point. Bottom line: still looking for solution. – alanxz Apr 08 '13 at 16:46

2 Answers2

2

This is what I use for editing markdown files, it should work c,cpp as well.

" Turn off completion, it's more disruptive than helpful
function! s:markdown_disable_autocomplete()
  if &ft ==# 'markdown'
    :NeoComplCacheLock
  endif
endfunction
autocmd MyAutoCmd BufEnter * call s:markdown_disable_autocomplete()
terryma
  • 181
  • 2
  • 5
2

Here's how I disabled NeoCompleCache for my .vimrc:

" Disable NeoComplCache for certain filetypes
if has('autocmd')
  autocmd FileType pandoc,markdown nested NeoComplCacheLock
 endif

References:

docwhat
  • 11,435
  • 6
  • 55
  • 54