Search code examples
vimclang-complete

Why does clang_complete in VIM give incomplete completion?


I am new to VIM and clang_complete. I managed to install clang_complete and it seems to work, but the completions are somehow not what I expect. For example, I looked at a tutorial and expect a behaviour like in this animated gif: https://blogueun.files.wordpress.com/2013/12/be5ee-using_clang.gif

This is what I do:

  • vim test.cpp
  • In VIM I hit i to get to insert mode
  • I press <C-x><C-u> to open the autocomplete list
  • I press <C-n> twice to select the second entry
  • I hit enter to confirm the selection

Now I have the following line in VIM:

using

But I think it should be something like:

using namespace $\'identifier' (the ' has to be replaced by `, please edit the question)

How can I get the full completion and not only the first word?


Solution

  • I found out myself. From the FAQ of clang_complete in https://raw.githubusercontent.com/Rip-Rip/clang_complete/master/doc/clang_complete.txt:

    *) Only function names get completed but not the parentheses/parameters.

    Enable the snippets-support by adding the following lines to your .vimrc, for example:

    let g:clang_snippets = 1

    let g:clang_snippets_engine = 'clang_complete'

    This worked for me.