0

I have used vim for C++ development for quite a while now where, for auto completion, i would either use YCM or, lately, the combination of LanguageClient-neovim and clangd. Lately, however, having been influenced by a few articles from vimways.org, i would like to explore a more ascetic auto-completion setup. Among several auto-completion flavours that vim offers, one can find "omni-completion", a context specific auto completion style with support for multiple languages. :h compl-omni-filetypes lists C as supported language and this is already a good start.

When looking further for omni-complete for C++, I find projects like OmniCppComplete but the last available version is quite dated: 2007. Given we get a new standard every 3 years since 2011, it feels that any C++ related tool should get a facelift every now and then.

I realize that i can always get back to the comfort of modern LSP in combination with a LSP client plugin, but what be the hard-core vim way to continue? The fewer plugins the better, right? Do vim ninjas among you say C style omni-complete is good for 80% of the cases? Or do you toss auto complete all together, claiming it hinders your learning progress of the code base?

  • 1
    LSP is great and a vast improvement over anything that came before it IMO (ctags, jedi, etc.) Don't let some pedantic random internet Vim purist dictate you that "this is the one and true only blessed Vim Way™" and distract you from getting stuff done. If LSP makes you productive and happy: use it. – Martin Tournoij Jun 5 '20 at 16:44
  • @MartinTournoij true, i agree that LSP is probably superior to most decade old solution (or older). What i am trying to find out is how much of the core Vim am I really overlooking.. Name it pure academic interest. For instance, i was surprise how far setting path to relevant folders and combining it with find and wildmenu could get you in terms of navigating through files in the project. I still would prefer my fzf integration, but what if i am using someone elses vim setup... – ambushed Jun 5 '20 at 17:43
  • 1
    Completion is much harder because it requires parsing the code to know 1) what symbols there are and 2) which one make sense in the current context. ctags mostly solves the first problem (although results vary per-language) but not the second. You can solve that in VimScript, but it's often inperfect. Using an external tool as omnicomplete solves both, but that's essentially what LSP is. For example for Go there was gocode which could be used like this, but for all intents and purposes it was basically just an ad-hoc LSP. I never managed to get good completion before LSP in Vim myself. – Martin Tournoij Jun 6 '20 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.