19

So after playing around with omnicpp, gccsense and clang_complete I couldn't get any of them to work. So I apt-get purge vim-* and tried again to install clang_complete, but without success.

Here's what I do:

  1. Download clang_complete.vmb, move it to my fresh, clean .vim dir and execute vim clang_complete.vmb -c 'so %' -c 'q'.

  2. Paste this into my .vimrc:

    syntax on
    set number
    filetype plugin on
    let g:clang_user_options='|| exit 0'
    let g:clang_complete_auto = 1
    let g:clang_complete_copen = 1
    
  3. Create a typical example

    #include <iostream>
    #include <string>
    
    int main() { std:: (I get: User defined pattern not found) }
    

Is there anything else I need to do/install to get it working? And silly question I've heard about Clang, do I need to apt-get install it?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mishe
  • 301
  • 1
  • 7
  • 15
  • 1. What kind of completion do you use in vim (keys you press)? 2. Try setting `g:clang_debug = 1` and see if you get any debug messages when you try to complete something, it should print some information every time the plugin is used for autocompletion. – ldx Apr 22 '12 at 14:30
  • 2
    Also see this how to set up clang_complete + supertab: http://zwiener.org/vimautocomplete.html – ldx Apr 22 '12 at 14:34
  • 1
    Thanks for tips, I've managed to get it working, for future seekers, it was like I need clang installed for it to work... – mishe Apr 22 '12 at 20:38

2 Answers2

25

clang_complete can be configured to use the clang executable or the clang library

clang_complete uses the clang executable by default but the clang library will execute lot faster

clang_complete plugin (using the clang executable) needs:

  1. clang must be installed in your system and be in the PATH
  2. do not set (let) g:clang_library_path to a path containing the libclang.so library

clang_complete plugin (using the clang library) needs:

  1. python installed in your system
  2. vim must be built with python support (do :version and look for a +python/dyn or +python3/dyn entry)
  3. set (let) g:clang_library_path to the directory path where libclang.so is contained
franckspike
  • 2,039
  • 25
  • 18
  • 2
    where is `libclang.so` located? for example on ubuntu – kirill_igum Nov 03 '12 at 21:46
  • 2
    ah, found it `/usr/lib/libclang.so` – kirill_igum Nov 03 '12 at 21:47
  • 2
    clang_complete plugin doesn't seem to work... `clang` is in my `PATH` and I'm not setting the clang_library_path, but I get "Loading libclang failed, completion won't be available. Consider setting g:clang _library_path." when using Ubuntu's libclang (version 3.5). My Ubuntu version is 14.10. – weberc2 Apr 20 '15 at 00:07
  • +1 for pointing out the difference between the executable and the library option. May be this is the reason,I was not able to fix this issue in past and jumped to YCM. But this time I tried this and clang_complete is working fine. Thanks. – Abinash Dash Dec 25 '20 at 18:41
4

let g:clang_library_path='/usr/lib/llvm3.5/lib/libclang.so.1' in my .vimrc and it works fine.