Recently I’ve had this idea of using Vim to continue development on my application. Most of the development is done in my desktop where I sit and fight wars with QtCreator. Now, there’s something I really enjoy about using YouCompleteMe is on how incredibly fast it is. The subsequence algorithm it uses is perfect (for me) as I can “lazy type” the things I want, something I can’t do in QtCreator autocomplete because it doesn’t have the same search mechanism as YCM.

Another reason is because QtCreator FakeVim isn’t that good; no matter how much I use it there’s always something lacking.

All you need to do to get this working is

  • Use CMake (… well, not really, cmake just makes it easier with CMAKE_EXPORT_COMPILE_COMMANDS to be ON either as a switch in your cmake call or as a variable in your CMakeLists.txt
  • Use clang, as far as I know it doesn’t work with GCC.
  • Have some basic knowledge of YCM extra configuration file.

It works incredibly well.

Before you comment

  • You can use Markdown in your comments, here's a guide.
  • Keep things civil.
  • That means don't do personal attacks.
  • Profanity is highly discouraged.

2 thoughts on “Working with YouCompleteMe + Vim + Clang/Cmake + Tmux

  1. Hello David,
    I just want to get an IntelliSense-like AutoCompletion, but my YouCompleteMe Config doesn’t really meet my needs:
    alt text
    The Completion-list appereared after I typed “+N”.
    May I see how your clang_config looks like?
    Regards, Patrick.

    1. Hey Patrick,

      As far as I know there’s really… nothing compared to Intellisense in linux that’s available in libre software. Closest thing I would say JetBrains products Clion which is pretty good.

      If you are new to this my instructions might be hard to grasp, this is completely fine.

      This is what you need to be looking for to configure YCM:

      • Get your include paths with (more info here)
      • Configure YCM’s .ycm_extra_conf.py
      • Add that file to your .vimrc (below an example)

      If I understand correctly you want to get YouCompleteMe working? Well, YCM requires extra configuration, for example to get it working you have to map your include files in the youcompleteme global configuration.

      Now! In my github I have my dotfiles available, take a look at my .vimrc configuration and .ycm_extra_conf.py.

      If you notice in my ycm_extra_conf there’s something rather unique in that file. (Important note: These include paths ARE DIFFERENT FOR EACH DISTRIBUTION. You need to edit them and put whatever clang echoed see the link in the “include paths” above )

      '-isystem', '/usr/local/include',
      '-isystem', '/usr/bin/../lib/clang/3.5.0/include',
      '-isystem', '/usr/include',
      '-isystem','/usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1',
      '-isystem','/usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux',
      '-isystem','/usr/bin/../lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/backward',
      

      See? Those were manually added. Now, if you take a look at my .vimrc you will see this line

      let g:ycm_global_ycm_extra_conf = '/home/david/.vim/.ycm_extra_conf.py'

      What this line does is that it will tell YouCompleteMe to read the include files and compile the information to provide you the autocomplete functionality.

      Beyond this I can’t really help that much . It should get you started but all depends on how much you know about linux and vim. I would suggest reading YCM’s documentation ( https://valloric.github.io/YouCompleteMe/ ) as it should get you started right away.

Comments are closed.