Handmade Network»Forums
Blake Martin
33 posts
Vim8/Neovim Setup for C++ Completion With Clang
Edited by Blake Martin on
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?

rudy
2 posts
Vim8/Neovim Setup for C++ Completion With Clang
Edited by rudy on
Yeah. The standard for Vim code completion is YCM (https://github.com/ycm-core/YouCompleteMe) 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 :-)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InsertTabWrapper()
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '\k'
        return "\<tab>"
    else
        return "\<c-p>"
    endif
endfunction
inoremap <expr> <tab> InsertTabWrapper()
inoremap <s-tab> <c-n>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""