neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.15k stars 953 forks source link

Hover/docstring information with custom sources #5003

Closed NoahTheDuke closed 1 month ago

NoahTheDuke commented 2 months ago

Hey friends,

I have a custom source created with sources.createSource. It implements ‎Source.doComplete to return vim completion items. I'm generating the completion items with doc strings, but there doesn't seem to be a way to display those on hover, like with LanguageSources.

LanguageSource.onCompleteResolve calls provider.resolveCompleteItem (here) which transforms the results from the server (here) to provide the lsp's fancy completionItem/resolve results.

I would like to be able to return similarly fancy results from my custom source, hovering docstrings and function signatures and whatever else. From looking at the code, it seems like it should be possible to just return the results of Source.onCompleteResolve instead of discarding them.

Would y'all be interested in a patch to support this?

fannheyward commented 1 month ago

Hello, correct me if I misunderstand your request.

You want to get the hover doc from completionItem that from your custom source, right? You don't need to use the results of source.onCompleteResolve, the resolved informations already added the item parameter.

And, how do you want to use the completionItem for hover docstring?

NoahTheDuke commented 1 month ago

My apologies, the issue was actually coming from the source. It wasn't returning hover info if the functions had no doc strings, which isn't any issue in coc.nvim.

Thanks and sorry!