Sunday, October 9, 2016

Re: Omni completation for C++

Hugo Gagnon <opensource.vim@user.fastmail.fm> wrote:

> Hello,
>
> What is the status of omni completion for C++ in Vim? In the tag "compl-omni" it says:
> "Currently there is a first version for C++". However, in the tag "compl-omni-filetypes"
> there is no mention of C++.
>
> If Vim has nothing built-in, is the plugin "OmniCppComplete" the only option left? I am
> not interested in plugins that require a real-time compiler such as with "YouCompleteMe".
>
> Thank you,
>
> Hugo

Why aren't you interested in YouCompleteMe?

I use the YouCompleteMe plugin for c++ and iI highly recommend it.
It does exact completion based on a real c++ parser (libclang) instead
of using heuristics. YouCompleteMe not does only does completion,
but the feature I prefer is that it shows compilation warnings and
errors in real time as I type asynchronously, It's very quick. It saves
time as it catches silly mistakes before I run make. YCM knows what
options to pass to the compiler by using the compile_commands.json
which is automatically created by cmake in my case, so it's very easy
to set up, even for large projects, but there are other ways to tell what
are the compiler flags.

Besides YouCompleteMe, I also also use rtags, also based on clang.
I use rtags to reliably:
- jump to definition
- jump to declaration
- find where a symbol is used
- find implementations of virtual function member
- find base class of a class
- find derived classes of a class

This is much better than ctags/cscope as rtags uses a real c++
compiler whereas ctags/cscope merely use heuristics. rtags and YCM
even works for libs like STL, boost, etc. You can jump to the definition
of an operator, erc. rtags also knows about compiler options using the
same compile_commands.json created by cmake.

One drawback of rtags is that is slow to index large projects.
YCM on the the other hand does not require to index the whole
project, it works by compiling the current file so it's very quick.

Still, I also use ctags/cscope as a fallback, as rtags requires the file
to compile correctly, whereas ctags/cscope can work even when the source
file does not compile. So ctags/cscope remain a useful fallback
in some cases.

When developing in c++, rtags and YouCompleteMe are hugely
helpful to understand c++ code. It's well worth the investment
to set them up with Vim.

Regards
Dominique

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: