deoplete-plugins / deoplete-clang

deoplete.nvim source for C/C++/Obj-C/Obj-C++ with clang-python3
MIT License
189 stars 73 forks source link

deoplete-clang get errors #59

Open andrea993 opened 7 years ago

andrea993 commented 7 years ago

Deoplete-clang doesn't work I get this error when it should complete the cpp syntax:

[deoplete] Could not get completions from: clang.  Use :messages for error details.   

:messages says:

[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 151, in gather_candidates                                                         
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
"pippo.cpp" 8L, 65C                                                                                  
[deoplete] Traceback (most recent call last):                                                        
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", l
ine 98, in gather_results                                                                            
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)                                     
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 151, in gather_candidates                                                         
[deoplete]     params)                                                                               
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 314, in get_completion                                                            
[deoplete]     tu = self.get_translation_unit(fname, args, buf)                                      
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 301, in get_translation_unit                                                      
[deoplete]     tu = self.index.parse(fname, args, buf, flags)                                        
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
ndex.py", line 2322, in parse                                                                        
[deoplete]     self)                                                                                 
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
ndex.py", line 2440, in from_source                                                                  
[deoplete]     raise TranslationUnitLoadError("Error parsing translation unit.")                     
[deoplete] clang.cindex.TranslationUnitLoadError: Error parsing translation unit.                    
[deoplete] Could not get completions from: clang.  Use :messages for error details.                  
[deoplete] Traceback (most recent call last):                                                        
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", l
ine 98, in gather_results                                                                            
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)                                     
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 151, in gather_candidates                                                         
[deoplete]     params)                                                                               
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 314, in get_completion                                                            
[deoplete]     tu = self.get_translation_unit(fname, args, buf)                                      
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/sources/deople
te_clang.py", line 301, in get_translation_unit                                                      
[deoplete]     tu = self.index.parse(fname, args, buf, flags)                                        
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
ndex.py", line 2322, in parse                                                                        
[deoplete]     self)                                                                                 
[deoplete]   File "/home/andrearch/.vim/bundle/deoplete-clang/rplugin/python3/deoplete/clang/clang/ci
ndex.py", line 2440, in from_source                                                                  
[deoplete]     raise TranslationUnitLoadError("Error parsing translation unit.")                     
[deoplete] clang.cindex.TranslationUnitLoadError: Error parsing translation unit.                    
[deoplete] Could not get completions from: clang.  Use :messages for error details. 

this is my init.vim https://arin.ga/pN1SjM

zchee commented 7 years ago

@andrea993 Thanks issue :)

Hmm.. I have not yet debug, will check it. Sorry, if you have time, could you post a sample C source at occurring this problem?

andrea993 commented 7 years ago

I have this issue with all .cpp files

#include <iostream>

using namespace std;

int main()
{
    std::
}

If. for example. I go at the end of std:: and I press a to write I get the error

zchee commented 7 years ago

@andrea993 I think your problem same as https://github.com/zchee/deoplete-clang/pull/54 That's not yet merged, but Could you try it?

Shougo commented 7 years ago

@andrea993

parnmatt commented 7 years ago

Rather than creating another issue, this issue seems to be similar if not the same.

I do not know what the compilation database file is, @Shougo, where would this file be located?

Minimal init.vim

" init.vim

" dein plugin manager
function! InstallPluginManager()
    echom 'Installing dein...'
    silent! call mkdir($XDG_CONFIG_HOME . '/nvim/dein', 'p')
    silent! execute '!curl --fail --location --output /tmp/dein.sh '
             \ . 'https://raw.githubusercontent.com/'
             \ . 'Shougo/dein.vim/master/bin/installer.sh'
    silent! execute '!sh /tmp/dein.sh ' . $XDG_CONFIG_HOME . '/nvim/dein'
endfunction

if !filereadable($XDG_CONFIG_HOME . '/nvim/dein/'
            \ . 'repos/github.com/Shougo/dein.vim/autoload/dein.vim')
    call InstallPluginManager()
endif

set runtimepath+=$XDG_CONFIG_HOME/nvim/dein/repos/github.com/Shougo/dein.vim
call dein#begin($XDG_CONFIG_HOME . '/nvim/dein')
call dein#add('Shougo/dein.vim')
call dein#add('Shougo/deoplete.nvim')
call dein#add('zchee/deoplete-clang')
call dein#end()

if dein#check_install()
    call dein#install()
endif

filetype plugin indent on
syntax enable
call deoplete#enable()
autocmd CompleteDone * pclose

The test file I used was:

// test.cc

#include <vector>

std

As typing the d in std the following errors were printed to :messages

[deoplete] Traceback (most recent call last):
[deoplete]   File "/home/parnmatt/.dotfiles/nvim/.config/nvim/dein/.cache/init.vim/.dein/rplugin/python3/deoplete/deoplete.py", line 100, in gather_results
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)
[deoplete]   File "/home/parnmatt/.config/nvim/dein/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 151, in gather_candidates
[deoplete]     params)
[deoplete]   File "/home/parnmatt/.config/nvim/dein/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 314, in get_completion
[deoplete]     tu = self.get_translation_unit(fname, args, buf)
[deoplete]   File "/home/parnmatt/.config/nvim/dein/.cache/init.vim/.dein/rplugin/python3/deoplete/sources/deoplete_clang.py", line 301, in get_translation_unit
[deoplete]     tu = self.index.parse(fname, args, buf, flags)
[deoplete]   File "/home/parnmatt/.config/nvim/dein/.cache/init.vim/.dein/rplugin/python3/deoplete/clang/clang/cindex.py", line 2322, in parse
[deoplete]     self)
[deoplete]   File "/home/parnmatt/.config/nvim/dein/.cache/init.vim/.dein/rplugin/python3/deoplete/clang/clang/cindex.py", line 2440, in from_source
[deoplete]     raise TranslationUnitLoadError("Error parsing translation unit.")
[deoplete] clang.cindex.TranslationUnitLoadError: Error parsing translation unit.
[deoplete] Could not get completions from: clang.  Use :messages for error details.
Shougo commented 7 years ago

I do not know what the compilation database file is, @Shougo, where would this file be located?

Hm. It is not specified. We should improve the error message. But where is your libclang installed? I think you need to set it like this.

let g:deoplete#sources#clang#libclang_path = '/usr/lib/libclang.so'
parnmatt commented 7 years ago

Indeed, libclang is located, and symlinked to /usr/lib/libclang.so -> libclang.so.3.9.

This is a standard place for the library to be located, and certainly should be in the library path. Why wouldn't this be found by neovim / deoplete-clang?

I will try the minimal configuration with the path hardcoded as suggested and get back to you.

Shougo commented 7 years ago

This is a standard place for the library to be located, and certainly should be in the library path. Why wouldn't this be found by neovim / deoplete-clang?

Unfortunately, it is not standard. This is for Ubuntu 16.04 configuration.

let g:deoplete#sources#clang#libclang_path = '/usr/lib/llvm-3.8/lib/libclang-3.8.so'
parnmatt commented 7 years ago

Yep correcting this has solved my issue. I correctly pointed libclang_path and clang_header to the correct paths.

However the moment I start typing #include it freezes (I assume looking for headers to complete; and uses ) for 5-10; and does so whenever I edit on that line.

Shougo commented 7 years ago

Yes, deoplete-clang has many performance problems. But it will be fixed by @zchee .

Cypher1 commented 7 years ago

I'm also having a similar problem, can we just get deoplete-clang to ignore lines that start with '#'?

(or have an option for that)

kierun commented 7 years ago

I have the same issue (I think?) but setting libclang_path and clang_header did not solve it. The really weird thing is that after the error, completion works just fine.

Is there something I can try to provide you with more debug information?

sshtmc commented 7 years ago

I have the same problem. Any update on the issue?

Shougo commented 7 years ago

You should use deoplete-clang2 instead.

https://github.com/tweekmonster/deoplete-clang2

Cypher1 commented 7 years ago

Why is there a second deoplete rather than a second version?

Shougo commented 7 years ago

Because, @zchee implements the new version of deoplete-clang. He is very busy. No time to fix the bugs in deoplete-clang currently.

Cypher1 commented 7 years ago

Hmm, fair enough, couldn't we just have branches to facilitate visibility and merging?

Deoplete is an awesome plugin, I'd hate to see two parts diverge and end up with incompatible features.

sshtmc commented 7 years ago

@Cypher1 I think there's a misunderstanding (from the eyes of a complete outsider). Deoplete is a separate project from deoplete-clang. Deoplete stays as is. However, deoplete-clang had too high code complexity (it seems) and now there's going to be deoplete-clang2.

But regardless of the above, I would also like to see deoplete-clang2 replace deoplete-clang (become version 2). IMHO there's no point in having deoplete-clang if it's full of bugs and nobody is maintaining it.

kierun commented 7 years ago

This is going to add to the confusions of users unless someone actually write this on the main README…

sshtmc commented 7 years ago

I just tried deoplete-clang2 (https://github.com/tweekmonster/deoplete-clang2) and it worked great, without any issues.

Shougo commented 7 years ago

@Cypher1 I think there's a misunderstanding (from the eyes of a complete outsider). Deoplete is a separate project from deoplete-clang. Deoplete stays as is. However, deoplete-clang had too high code complexity (it seems) and now there's going to be deoplete-clang2.

Yes.

But regardless of the above, I would also like to see deoplete-clang2 replace deoplete-clang (become version 2). IMHO there's no point in having deoplete-clang if it's full of bugs and nobody is maintaining it.

I like deoplete-clang than deoplete-clang2. deoplete-clang will be rewritten.

Deirdan commented 7 years ago

Hi! I have the same problem. My PC is on Debian testing. My libclang is at /usr/lib/llvm-3.8/lib/libclang.so. I tried deoplete-clang2 but I get errors too, even if I write let g:deoplete#sources#clang#executable='/usr/bin/clang', let g:deoplete#sources#clang#executable='/usr/bin/clang2' or let g:deoplete#sources#clang#executable='/usr/bin/clang-3.8'.

Have you an idea?

Thanks.

Shougo commented 7 years ago

I tried deoplete-clang2 but I get errors too, even if I write let

You should create new issue in deoplete-clang2.