Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically displaying function documentation (i.e. LspHover) while typing? #275

Closed
fgimian opened this issue Feb 2, 2019 · 11 comments
Closed

Comments

@fgimian
Copy link

fgimian commented Feb 2, 2019

Hey there, thanks so much for your amazing work on this plugin for vim 😄

When using LSP in Sublime Text, I can easily see function documentation in a little tooltip as I type:

screen shot 2019-02-02 at 11 24 45 pm

When using vim-lsp and vim, I can see the suggestions as I type:

screen shot 2019-02-02 at 11 29 07 pm

However, this popup disappears when I open my brackets to type the parameters. Is there a way to keep this displayed and highlight which parameter I'm currently entering like Sublime Text does above?

Further to this, it seems the only way to see documentation once I type the opening bracket is to use the :LspHover command, which gives me this:

screen shot 2019-02-02 at 11 29 27 pm

Is there a way to display this information automatically as you are typing?
I also noticed that this documentation would disappear after I started typing my parameter names in the brackets too. Not sure if there's a way to avoid that happening.

I attempted to explicitly set completeopt to include preview but that didn't seem to help.

Any help is greatly appreciated
Fotis

@fgimian
Copy link
Author

fgimian commented Feb 2, 2019

So I've managed to get one step closer. I had to do the following to see automatic previews of functions:

let asyncomplete_auto_completeopt = 0
set completeopt=menuone,noinsert,noselect,preview

It seems that set completeopt+=preview simply won't work because completeopt is completely overridden by asyncomplete.vim. I'm not sure if this is a bug?

So I guess the main questioning remaining is, is there a way to see the function signature or preview window while typing function arguments? vim-go seems to have attempted this 😄

Cheers
Fotis

@fgimian
Copy link
Author

fgimian commented Feb 2, 2019

So unfortunately the solution I place above doesn't show full documentation that LspHover does.

e.g. here is the preview window

screen shot 2019-02-03 at 9 23 25 am

And here's LspHover:

screen shot 2019-02-03 at 9 24 27 am

Clearly I'm missing something here 😄

Any help is greatly appreciated
Fotis

@mikew
Copy link

mikew commented Feb 18, 2019

Looks like textDocument/signatureHelp exists in LSP. There was even an issue created here for it, but the author closed it. #53

vim-lsc seems to have support for it: https://github.com/natebosch/vim-lsc/blob/c6d088d86cf485567cdafcf451c8b265b1620efe/autoload/lsc/signaturehelp.vim#L17-L54

@fgimian
Copy link
Author

fgimian commented Feb 18, 2019

Looks like textDocument/signatureHelp exists in LSP. There was even an issue created here for it, but the author closed it. #53

vim-lsc seems to have support for it: https://github.com/natebosch/vim-lsc/blob/c6d088d86cf485567cdafcf451c8b265b1620efe/autoload/lsc/signaturehelp.vim#L17-L54

Thanks a lot for the reply. I also found deoplete does it well, so I may try that again too.

So far vim-lsp has been my favourite LSP plugin so would be lovely if it supported this functionality in future.

Kindest Regards
Fotis

chiroptical added a commit to chiroptical/neovim-setup that referenced this issue Feb 21, 2019
@prabirshrestha
Copy link
Owner

MenuPopupChanged neovim/neovim#9616 and floating windows should allow this in the future. Will wait for it to stabilize first.

@mkwork
Copy link
Contributor

mkwork commented Mar 5, 2019

@prabirshrestha, did you know that jedi-vim has this feature implementation? It's quite tricky and my vim coding skills are too low for this implementation generalization. But, may be you would like to have a look.

@prabirshrestha
Copy link
Owner

There is a discussion going on floating window. Will take time for vim to support it. Neovim support was merged this week. vim/vim#4063

I would rather wait for a proper floating window support and have something like this instead instead of hacks. I'm not a fan of the preview window as it flickers the buffer too much.

image

@mkwork
Copy link
Contributor

mkwork commented Mar 5, 2019

It's implemented within conceal instead of preview windows or other echodoc style distractive workrarounds :) Yep it's dirty hack. But it works like a charm, just try it on any python helloworld.

default

default

default

@zorgick
Copy link

zorgick commented May 8, 2020

@prabirshrestha any news? Is it implemented already? Man, I am fascinated by your plugin and I don't want to move again to another autocompletion plugin, but I'm really in lack of this feature.

@paltom
Copy link

paltom commented Jun 16, 2020

@prabirshrestha are you going to support this? Now that Vim has popup_create and CompleteChanged it should be possible to implement this. This feature works in coc.nvim but it lefts artifacts when changing completion items and I prefer your LSP plugin anyway.

@dezza
Copy link

dezza commented Apr 28, 2021

I see that the popup triggers on the latter arguments as well

__________________popup_happens
function (arg1, <cursor>)

The only issue I see with this is the closing/reopening of the popup (slight distraction) and the lack of highlight on the "current" argument.

I guess the highlighting of current argument will take a little effort to implement.

If you want the signature always displayed you can do "echodoc.vim" similar behaviour by doing:

        echo get(l:contents, 0, '')

after line 80
https://github.com/prabirshrestha/vim-lsp/blob/master/autoload/lsp/ui/vim/signature_help.vim#L80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants