clang_complete icon indicating copy to clipboard operation
clang_complete copied to clipboard

Does not work at after pressing . or :: What should I do in order to make it work?

Open jlstr opened this issue 9 years ago • 17 comments

Hello, I've been trying to use this Vim plugin and so far no success whatsoever. For example:

std::

doesn't do anything when I stop typing. Or:

std::vector<int> vec;
vec.

doesn't show any drop-down with methods either. I have no idea what to do in order to make it work, I have tried many of the options found in the docs: https://github.com/Rip-Rip/clang_complete/blob/master/doc/clang_complete.txt, Also, I have tried some of the answers in StackOverflow, etc

but it won't work at all. What should I do? I don't even know where to begin.

jlstr avatar Nov 01 '15 18:11 jlstr

Hello, I am experiencing this same issue on neovim with deoplete + clang_complete: https://github.com/Shougo/deoplete.nvim/issues/125#issuecomment-172286463

@shougo: Can you elaborate on what the problem seems to be?

tony avatar Jan 18 '16 03:01 tony

https://github.com/Rip-Rip/clang_complete/blob/master/rplugin/python3/deoplete/sources/clang_complete.py#L16

min_pattern_length should be 0.

Shougo avatar Jan 18 '16 03:01 Shougo

Good thing that this issue was mentioned, because, I've recently installed clang_complete for Vim in a different machine (Mac OS X) and I'm experiencing similar problems, I have had no problems while using the scope operator std::, that one completes just fine. BUT vec. dot-type of completions don't always work retro-actively. ie. If I close VIM, then re-start it, then re-open a .cpp I was working on, then this type of completion vec. usually Does Not work! (Diplays the infamous: User defined completion (^U^N^P) Pattern not found error), I read in the docs it's possibly because of some kind of VIM buffer thing or something?

Here's what I have on my .vimrc file:

let g:clang_library_path = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib'
let g:clang_use_library = 1
let g:clang_user_options='|| exit 0'
let g:clang_close_preview = 1
let g:clang_snippets = 1
let g:clang_trailing_placeholder = 1

Notice that I'm pointing to XCode's installed libclang, I've always wondered if it's best to point to a clang installed separately via brew, but there aren't many guides out there on how to configure it that way

jlstr avatar Jan 18 '16 17:01 jlstr

@jlstr, I would expect that if :: completion works, then . completion should work the same way. Maybe check :inoremap <buffer> . for unexpected handlers, which could be set up by another plugin.

xaizek avatar Jan 18 '16 19:01 xaizek

Hello there, thank you for the reply! here's the rest of .vimrc file, sir.

set background=dark
set backspace=indent,eol,start
set completeopt=preview,menuone
set cpoptions=aAceFsB
set expandtab
set fileencodings=ucs-bom,utf-8,default,latin1
set guitablabel=%M%t
set helplang=en
set langmenu=none
set mouse=a
set shiftwidth=2
set tabstop=2
set termencoding=utf-8
set updatetime=2000
" vim: set ft=vim :
command! -nargs=* -bar -bang -count=0 -complete=dir E Explore <args>
colorscheme kalisi
set number

set nocompatible
filetype off

I have nothing else in it. What do you think?

jlstr avatar Jan 20 '16 03:01 jlstr

filetype off

Why? This might be the reason completion doesn't work for you. Try setting filetype on instead.

xaizek avatar Jan 20 '16 08:01 xaizek

Didn't work, sir. Moreover... The problem is worse than I imagined, now all method dot completions aren't working: https://www.youtube.com/watch?v=rlQPgLfaacc

Here's my actual complete .vimrc file too: https://gist.github.com/jlstr/f8ae21a39f831831e24f

jlstr avatar Jan 20 '16 15:01 jlstr

Hello again! I really really hope you can help me out with this issue, I have removed ALL the other plugins that I had installed, re-installed clang_complete, and reduced my .vimrc file to the most basic version I could: https://gist.github.com/jlstr/0772c15b65bc3f054564

And still, the problem remains! I can't do any completions of the type: vec. (See video above).

This is driving me crazy, I can't get it to work, and I'm sure I have Googled the entire internet for answers.... but no luck.

Thank you very much in advance.

jlstr avatar Jan 21 '16 18:01 jlstr

Maybe try using different libclang? In case current one can't find corresponding headers.

Hm, maybe python bindings to libclang used by clang_complete are too outdated and something goes completely wrong... That could probably explain what's going on here.

xaizek avatar Jan 21 '16 18:01 xaizek

Interesting observations sir! now that you mention using a different libclang, I have to say that I recently installed Android Studio, and apparently it comes with its own libclang. ie. /Users/jose/Library/Android/sdk/build-tools/23.0.2/lib/libclang.dylib And If I put that one in my .vimrc file it causes an error:

Loading libclang failed, completion won't be available. Are you sure '/Users/jose/Library/Android/sdk/build-tools/23.0.2/lib' contains libclang?

So, The obvious question is: Which different libclang do I install?, I have a gut feeling the problem is indeed libclang, but for Mac OS X the only that seems to be available..

$ brew search clang
clang-format     clang-omp     emacs-clang-complete-async           

is clang-omp (https://clang-omp.github.io/), Do you recommend installing that one?

jlstr avatar Jan 21 '16 19:01 jlstr

Regarding the python bindings, I have No Idea what are those, are those related to the --with-python install option macvim has?

jlstr avatar Jan 21 '16 19:01 jlstr

Please stop calling me "sir", it makes me feel uncomfortable :-)

Not an OS X user, just saw you mentioned homebrew having it. I think it might come with LLVM if you enable building clang for it (if it's not built by default).

Bindings are these: https://github.com/Rip-Rip/clang_complete/tree/master/plugin/clang They are required to be able to use libclang from python and are really old.

Also try setting let g:clang_debug = 1, not sure how useful additional output will be, but anyway.

xaizek avatar Jan 21 '16 20:01 xaizek

I use OS X 10.11.3 + mavim, this setting works for me.

let g:clang_library_path="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib"
1

jsfaint avatar Jan 22 '16 07:01 jsfaint

Hi @jsfaint, thank you for your reply. I have the exact same line to invoke Xcode's installed libclang, but variable-dot type completions (vec1.) just don't work for me [see video link above]. I tried to uninstall macvim (that was installed via brew), and re-installed/compiled from source; I did this process twice, because when I installed clang_complete the first time, Vim warned me it wouldn't work unless I compiled with python... Therefore I did that, and I thought I was getting somewhere, but It didn't work either!

I also installed LLVM which indeed comes with its own version of libclang, but it didn't work either. So, I think I have officially given up with this plugin. Sad part is... YouCompleteMe has the exact same problem. Even though it installed perfectly, its output points to a myriad of live-compilation problems, mostly about missing headers, and protected variables. Headers that I don't think belong to core C++ btw. Anyways, that's my story, I don't know why it worked in my other Mac OS X computer seamlessly and it's so problematic in a new machine. Thank you for your replies guys.

jlstr avatar Jan 22 '16 14:01 jlstr

@xaizek Sorry, clang_complete.py should set input_pattern instead of min_pattern_length.

https://github.com/zchee/deoplete-go/issues/7

Shougo avatar Jan 26 '16 12:01 Shougo

@Shougo, thanks for the notice, updated.

xaizek avatar Jan 26 '16 15:01 xaizek

:+1:

Shougo avatar Jan 26 '16 18:01 Shougo