Languageclient-neovim: Add support for calling LSP completionItem/resolve implementation when completion items are selected

Created on 24 Aug 2019  ·  8Comments  ·  Source: autozimu/LanguageClient-neovim

(I originally posted this over in the deoplete repo (#1004) because I thought that might be the right place for it, but @Shougo seems to think this is best handled inside LanguageClient-neovim, so I'm creating this ticket to see if that's correct.)

Looking at the LSP spec, I see this (emphasis added):

If computing full completion items is expensive, servers can additionally provide a handler for the completion item resolve request (‘completionItem/resolve’). This request is sent when a completion item is selected in the user interface. A typical use case is for example: the ‘textDocument/completion’ request doesn’t fill in the documentation property for returned completion items since it is expensive to compute. When the item is selected in the user interface then a ‘completionItem/resolve’ request is sent with the selected completion item as a parameter. The returned completion item should have the documentation property filled in.

To this effect, LanguageClient-neovim implemented a LanguageClient#completionItem_resolve() function that can be called to get additional information about a completion. The obvious use-case here is to show info about the selection completing in a preview window (or floating window).

As far as I can tell, LanguageClient-neovim sets its LanguageClient#complete() function as the 'omnifunc', and deoplete calls that to get completions. But when you move through completions, deoplete doesn't call LanguageClient#completionItem_resolve() and so doesn't get the extra info that an LSP server might provide. One such example server would be typescript-language-server, which doesn't provide extended information for textDocument/completion requests, but does implement completionItem/resolve.

So this is really a feature request. Could we have an option to make deoplete call an LSP completionItem/resolve function when completion items are selected? This means that 'completopt=preview' would be more useful, because it would have information to show about selected completions in more cases. coc.nvim implements this, in case you wanted to check out what they're doing.

Looking into :h CompleteChanged, I see that support for it was added to Neovim here by @chemzqm (the Coc maintainer).

It's still not clear to me exactly where the responsibility for this functionality should lie (that's why I opened the issue in deoplete; but it may be here), but the end goal is to have something like what you can see in the GIF in the Coc README:

https://user-images.githubusercontent.com/251450/55285193-400a9000-53b9-11e9-8cff-ffe4983c5947.gif

You can see how the completion menu appears, and then, asynchronously, a floating preview appears to the side with additional information about the selected completion:

Screen_Shot_2019-08-24_at_21_10_47_png

Thoughts?

feature request

Most helpful comment

Opened #1043 to try and kicks things off here. Appreciate the extra eyes if someone can take a look and try it out.

All 8 comments

Has anyone started working on this already?

Yeah it works fine, although I haven't found a way to get it to show previews like this yet.

@wincent nice! how is the previews shown? 🤔 in the preview window? :eyes:

@take I made a short screencast on it a few weeks ago. Since then I tweaked a few things (mostly color related) to make it look nicer, but you can get a sense of the basics behavior from that.

Opened #1043 to try and kicks things off here. Appreciate the extra eyes if someone can take a look and try it out.

Just updated that PR to properly work in neovim 0.4.X+ and vim8. I'll give it a ride for a few days and merge if all is working correctly.

Closing via #1043

Was this page helpful?
0 / 5 - 0 ratings