justmao945 / vim-clang

Clang completion plugin for vim
ISC License
357 stars 47 forks source link

Don't autofill first entry when autocompleting with neocomplete #104

Closed skyegecko closed 8 years ago

skyegecko commented 8 years ago

Hi,

I'm having some issues getting my configuration set up. At the moment it looks like this:

"#############################################################################
"### Neocomplete settings                                           {{{1    ##
"#############################################################################
if has('lua')
    let g:neocomplete#enable_at_startup = 1
    let g:neocomplete#enable_smart_case = 1
    let g:neocomplete#sources#syntax#min_keyword_length = 3
endif

" C(++) input patterns for neocomplete to open omnicomplete from vim-clang
let g:neocomplete#force_omni_input_patterns.c =
    \ '[^.[:digit:] *\t]\%(\.\|->\)\w*'
let g:neocomplete#force_omni_input_patterns.cpp =
    \ '[^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w*'

"#############################################################################
"### vim-clang settings                                             {{{1    ##
"#############################################################################
let g:clang_auto = 0    " disable own autocompletion as neocomplete takes over

" 'longest' option does not work with neocomplete
let g:clang_c_completeopt = 'menuone,preview'
let g:clang_cpp_completeopt = 'menuone,preview'

" Use 2011 standards by default
let g:clang_c_options = '-std=gnu11'
let g:clang_cpp_options = '-std=c++11'

When triggering the autocompletion, for example by typing std::, the first entry in the menu is automatically entered into the buffer (for example, std::advance). I would like for this not to occur.

I have tried the following additional settings, without success:

What am I doing wrong?

Shougo commented 8 years ago
let g:clang_c_completeopt = 'menuone,preview,noinsert'
let g:clang_cpp_completeopt = 'menuone,preview,noinsert'
skyegecko commented 8 years ago

Thank you, that works.

Is that option documented anywhere? I couldn't find it in the help file.

edit: actually it doesn't work. It seems that when opening the file, the first autocompletion will not fill the first result. Afterwards all completions are automatically filled, even with that option set.

edit2: some further troubleshooting later, it appeared that I'd lost some symlinks and vim was reading out of an old vimrc that didn't contain my new settings (I had to restore from backup a couple of weeks ago). My original settings (without the noinsert) worked as expected.

Thanks for the help Shougo, love your plugins!

unphased commented 7 years ago

The config doesn't work because it resolves the first item getting filled in (and subsequent typing not able to change it), but now the behavior becomes: the first result (which is almost always right) is never filled in, so i have to press Tab and Shift+Tab just to get it to fill the first result...

Shougo commented 7 years ago

@unphased You can press <CR> or <C-y> to insert the first candidate.