Nabil Sham
Nabil Sham

Reputation: 2355

make omnifun default in vim insert completion

after installing eclim and ycm in vim, when you start typing vim will use -- user defined completion in the popup menu, you can switch to Omni completion, which set up to display eclim options with c-x c-o.

How do I make vim user Omni completion options and not user defined option by default without having to press c-x c-o every time ?

if I understand correctly the chain should go:

completefunc -(calls)> omnifunc -(calls)> eclim options

instead completefunc is calling user defined completion by default, and will switch to omnifunc on c-x c-o

Upvotes: 0

Views: 3376

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172758

Apart from the default <C-n> completion (whose sources can be configured via the 'complete' option), Vim has two custom completions, namely user and omni completion. The only difference is in the trigger keys (<C-x><C-u> vs. <C-x><C-o>) and option names for the function names. To use the omnifunction with the userfunction keys, simply re-assign the function name after the omnifunc has been set:

:let &omnifunc = &completefunc

Upvotes: 2

Dave Day
Dave Day

Reputation: 11

This is from my current ~/.vim/vimrc:

" Eclim + YouCompleteMe {{{1
" See <~/MyDocs/SysAdmin/Eclim.otl>
" This next line recommended by Eclim installation instructions

autocmd FileType php,java,ruby let g:EclimCompletionMethod = 'omnifunc'

" For your list of filetypes where you want Eclim semantic completion 
" as the default YCM completion mode:

autocmd FileType php,java,ruby,c,cpp,perl,python  
    \if &completefunc != '' | let &omnifunc=&completefunc | endif

" This will allow you to hit <Enter> in normal mode to search for the
" word under the cursor

nnoremap <silent> <buffer> <cr> :PhpSearchContext<cr>
" End Eclim + YouCompleteMe }}}1 

I found that I needed to have &omnifunc = &completefunc when I want to use Eclim's semantic completion.

I am not sure I understand completely but, it looks like Eclim expects omnifunc and YCM expects completefunc, where User completion = completefunc and Omni completion = omnifunc

Upvotes: 1

Related Questions