Register»Forums»Vim8/Neovim Setup for C++ Completion With Clang
Blake Martin
34 posts
Vim8/Neovim Setup for C++ Completion With Clang
9 months, 1 week ago Edited by Blake Martin on April 22, 2020, 12:50 a.m.
Since 4coder doesn't have an official Vim setup just yet, I'm setting up Neovim/Vim8 the best I can. The only thing that is left is to get better completion than you can get with vim-gutentags. Ideally, I want to get to feature parity with Qt Creator + FakeVim, which was my previous setup before Qt Creator got a lot worse.

If I had a project that was completely self contained, it wouldn't matter, but I want to move from OpenGL to D3D 11, so tag-based completion becomes a bit annoying, since the D3D C++ APIs use methods (I know there's a C API). What I would like is a minimal, clangd-based plugin that is easy to configure, or something equivalent.

I have looked online, and the available plugins seem to want me to install python and npm and/or are bloated and complicated.

Presumably someone around here has something like this setup? What are you using?

1 posts
Vim8/Neovim Setup for C++ Completion With Clang
9 months, 1 week ago Edited by rudy on April 24, 2020, 6:35 p.m.
Yeah. The standard for Vim code completion is YCM ( which, as you said requires Python and a local node server. The reason is so that everything runs off the server and is a super quick call instead of hogging up your vim config stuff - I have used it before, it actually works okay.

Nowadays though, I just use VIM's built in autocomplete which is pretty good. I simply remap the default autocomplete keys to tab and set up a function to autocomplete with tab if im in the middle of a word, otherwise it defaults to normal tab functionality.

9 lines and a true handmade solution :-)

function! InsertTabWrapper()
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '\k'
        return "\<tab>"
        return "\<c-p>"
inoremap <expr> <tab> InsertTabWrapper()
inoremap <s-tab> <c-n>