Shougo / echodoc.vim

Print documents in echo area.
Other
578 stars 32 forks source link

Not showing arguments with deoplete + rtags #97

Closed qwence closed 3 years ago

qwence commented 3 years ago

I'm using deoplete with rzaluska/deoplete-rtags for C++. As you can see in the screencast below, deoplete is correctly recognizing the signature of the function being typed, but echodoc only gives the popup myfunc() instead of myfunc(int x, int y).

Screencast: https://asciinema.org/a/VI5qopfM7kckYpqYZHMoWAj72

Minimal init.vim

set nocompatible
colorscheme delphi
filetype plugin indent on
syntax enable
set mouse=a
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'Shougo/deoplete.nvim'
Plugin 'rzaluska/deoplete-rtags'
Plugin 'Shougo/echodoc.vim'
call vundle#end()            " required
filetype plugin indent on    " required

let g:deoplete#enable_at_startup = 1

let g:echodoc#enable_at_startup = 1
let g:echodoc#type = 'floating'
highlight link EchoDocFloat Pmenu

example.cpp

#include <iostream>

int myfunc(int x, int y){
    return x+y;
}

int main(int argv, char** argc){
    std::cout << myfunc(5,6);
}

Makefile (for the rtags setup)

sample:
    g++ -g -o./example example.cpp -I./ -std=c++14 -O0 -Wfatal-errors

Instructions for using the rtags plugin (after installing it): install rtags and bear, copy example.cpp and Makefile into a directory, and run

bear -- make
rdm &
rc -J
rc --reindex
Shougo commented 3 years ago

Fixed.

qwence commented 3 years ago

Thanks for looking into this! I tried the updated version on the example above and am getting the following error after entering insert mode and typing one character:

[deoplete] Traceback (most recent call last):
  File "/home/qwence/.vim/bundle/deoplete.nvim/rplugin/python3/deoplete/child.py", line 203, in _gather_results
    result = self._get_result(context, source)
  File "/home/qwence/.vim/bundle/deoplete.nvim/rplugin/python3/deoplete/child.py", line 267, in _get_result
    ctx['candidates'] = source.gather_candidates(ctx)
  File "/home/qwence/.vim/bundle/deoplete-rtags/rplugin/python3/deoplete/sources/deoplete_rtags.py", line 44, in gather_candidates
    completions_json = json.loads(stdout_data_decoded)
  File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Error from rtags: Expecting value: line 1 column 1 (char 0)  Use :messages / see above for error details.
Shougo commented 3 years ago

It is not deoplete or echodoc problem. It is deoplete-rtags problem. The json data seems broken.

Shougo commented 3 years ago

https://github.com/rzaluska/deoplete-rtags/blob/master/rplugin/python3/deoplete/sources/deoplete_rtags.py#L44

It should catch JSON errors.

Shougo commented 3 years ago

You can create issue for deoplete-rtags but it is old source. It may not be supported.

qwence commented 3 years ago

Never mind; it works now. (It turns out I'd accidentally killed rdm so that was producing an error message instead of json.) Thanks for the fix!

Shougo commented 3 years ago

Oh, OK.

Shougo commented 3 years ago

I have created ddc-rtags. You can use it instead.

https://github.com/Shougo/ddc-rtags