Closed roxma closed 6 years ago
at my side, gd works well on libc function, but does not work on local API exported in head file. my project is written in C.
I get this error with latest code Does anything change recently?
@jsfaint
Ah. I haven't synced my local changes. It should be fixed now.
I concluded that this issue is caused by libclang python binding.
Closing this issue now.
Open new issue if we have other cases.
works for me now, thanks
I'm just curious that how does clang_complete jump back with <C-t>
, then I read the code.
if !exists('g:clang_jumpto_back_key')
let g:clang_jumpto_back_key = '<C-T>'
endif
execute "nnoremap <buffer> <silent> " . g:clang_jumpto_back_key . " <C-O>"
brilliant😂
update ncm2/ncm2-pyclang to latest commit(Jul 24). ncm2 complain error at my project. gd works well on libc function, like dup2, it will open head file, and jump to prototype.
[ncm2_pyclang_proc@yarp] /Users/michael/github/tea/src/terminal.h:35:10: fatal error: 'aev.h' file not found
[ncm2_pyclang_proc@yarp] /Users/michael/github/tea/src/tea.h:39:21: error: field has incomplete type 'struct aev_
loop'
[ncm2_pyclang_proc@yarp] /Users/michael/github/tea/src/tea.h:43:5: error: unknown type name 'aev_io'
[ncm2_pyclang_proc@yarp] /Users/michael/github/tea/src/terminal.h:42:51: error: unknown type name 'aev_io'
[ncm2_pyclang_proc@yarp] /Users/michael/github/tea/src/terminal.h:53:5: error: unknown type name 'aev_io'
[ncm2_pyclang_proc@yarp] /Users/michael/github/tea/src/terminal.h:56:5: error: unknown type name 'aev_io'
[ncm2_pyclang_proc@yarp] /Users/michael/github/tea/src/terminal.h:68:33: error: unknown type name 'aev_io'
[ncm2_pyclang_proc@yarp] /Users/michael/github/tea/src/tea.c:256:9: warning: implicit declaration of function 'ae
v_loop_init' is invalid in C99 [-Wimplicit-function-declaration]
[ncm2_pyclang_proc@yarp] /Users/michael/github/tea/src/tea.c:265:5: warning: implicit declaration of function 'ae
v_run' is invalid in C99 [-Wimplicit-function-declaration]
Cannot find declaration
I'm not sure where is wrong. please help!
@butterflyfish
If goto declaration fails, ncm2-pyclang will report diagnostics. So that you could find what's wrong with the plugin and your settings.
Try using the clang
command to compile the .c
file using the options defined in your compile_commands.json
make --- it will produce compile_commands.json under build
I cannot reproduce this step.
@roxma, pls help check output log below. source file can be compiled by clang.
~/github/tea master ⇡
❯ ls
BUGS.md LICENSE NEWS.md TODO.md deps screenshot.png
FAQ.md Makefile README.md config.mk make src
~/github/tea master ⇡
❯ make CC=clang
Compile file deps/ek/kermit.c
Create archive build/lib/libkermit.a
Compile file deps/libaev/aev.c
Compile file deps/libaev/example.c
Create archive build/lib/libaev.a
Compile file src/cli.c
Compile file src/kermit_io.c
Compile file src/serial.c
Compile file src/tea.c
Compile file src/telnet.c
Compile file src/terminal.c
Compile file src/xymodem.c
Compile file src/xymodem_io.c
tea is produced under build/bin
~/github/tea master ⇡
❯ ls build
bin compile_commands.json dep lib obj
~/github/tea master ⇡
❯ cat build/compile_commands.json|grep tea.c
"command": "clang -O3 -I deps/ek -I deps/libaev -DNODEBUG -c src/tea.c -o build/obj/src/tea.o",
"file": "/Users/michael/github/tea/src/tea.c"
~/github/tea master ⇡
❯ clang -O3 -I deps/ek -I deps/libaev -DNODEBUG -c src/tea.c -o build/obj/src/tea.o
~/github/tea master ⇡
❯
@butterflyfish
The compile_commands.json
generated by your build system is not valid json.
You need to remove the trailing comma.
You also need to make sure that the c/cpp file name is the last part of the command
in compile_commands.json
.
Current argument parsing is a bit silly. It's hard to parse the arguments precisely without clang-c interface.
@roxma thx. after remove trailing comma, I got
Error detected while processing function ncm2_pyclang#goto_declaration[1]..ncm2_pyclang#find_declaration[1]..yarp#core#request:
line 2:
TranslationUnitLoadError('Error parsing translation unit.',)
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/neovim/msgpack_rpc/session.py", line 191, in handler
rv = self._request_cb(name, args)
File "/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/neovim/api/nvim.py", line 198, in filter_request_cb
result = request_cb(name, args)
File "/Users/michael/.vim/plugged/nvim-yarp/pythonx/yarp.py", line 23, in on_request
return getattr(module_obj, method)(*args)
File "/Users/michael/.vim/plugged/ncm2-pyclang/pythonx/ncm2_pyclang_proc.py", line 435, in find_declaration
tu = self.get_tu(filepath, args, directory, src)
File "/Users/michael/.vim/plugged/ncm2-pyclang/pythonx/ncm2_pyclang_proc.py", line 158, in get_tu
for_completion=for_completion)
clang.cindex.TranslationUnitLoadError: Error parsing translation unit.
Cannot find declaration
OS is MAC.
Argument parsing has been improved. It is not perfect, but it should work most of the time. @butterflyfish Could you test the latest master ?
I'm not sure whether this is a bug.
Save an issue here in case I forget to fix it.