LanguageClient-neovim icon indicating copy to clipboard operation
LanguageClient-neovim copied to clipboard

Better display of signature help

Open phil-nelson opened this issue 6 years ago • 14 comments

I am trying to work out a good way to display signature help. This includes documentation.

It would be great to display popup information but I can't see any way to do this, probably requires quite some work.

Next best I've come up with is displaying information in the preview window, like what YCM does. I've done a quick hacky implementation of this and it looks okay:

signaturehelp

Any other ideas?

phil-nelson avatar Dec 06 '17 04:12 phil-nelson

I was informed that jedi-vim integrates signature help with completion menu. Haven't got time to look into it and don't know how much work it would require.

Actually I made similar stuff at https://github.com/autozimu/LanguageClient-neovim/commits/infobuf.

Another thing is that, the work might be out of scope of this project. IMO, it would be better fitted into completion plugins, like deoplete and NCM.

autozimu avatar Dec 06 '17 06:12 autozimu

What jedi-vim does:

I would love to see something like that, currently signature help is too often overshadowed by other messages.

DerWeh avatar Dec 06 '17 06:12 DerWeh

@autozimu jedi-vim change the context of last line。 and use conceal syntax highlight.

you can check out SpaceVim's implement of signature API.

it will use conceal cchat instead of change the content of buffer. I think it is better.

BTW Vim has a bug about cchar.

for more info, please read

https://github.com/SpaceVim/SpaceVim/pull/1036

https://github.com/neomake/neomake/issues/1769

wsdjeg avatar Dec 25 '17 06:12 wsdjeg

and I also think this featureshould be added in complete plugin. languageclient-neovim could provide information for the signature help.

wsdjeg avatar Dec 25 '17 06:12 wsdjeg

cquery supports the command line option `--enable-comments' now (experimental and subject to change).

textDocument/hover seems fine in VSCode because they use a popup window. But for Emacs and Neovim, one-line signature displaying on the status bar looks better. I still wonder how language servers should support multi-line hover information with comments

//! foo
//! bar
int a;

experimental cquery --enable-comments

MaskRay avatar Dec 25 '17 08:12 MaskRay

I think that using floating window to show the documentation under cursor would be best experience, it would not change layout as preview window. But it's not merged https://github.com/neovim/neovim/pull/6619 yet.

chemzqm avatar Apr 28 '18 14:04 chemzqm

This patch works well enough for my use case, it mimics deoplete-jedi's behavior of putting the signature in the description, this way deoplete will show it in the preview window.

--- a/src/languageclient.rs
+++ b/src/languageclient.rs
@@ -1969,11 +1969,18 @@ impl State {
             snippet = String::default();
         };
 
-        let info;
+        let mut info = String::new();
+        if lspitem.kind == Some(lsp::CompletionItemKind::Function) {
+            if let Some(ref sig) = lspitem.detail {
+                info.push_str(sig.as_str());
+            }
+        }
         if let Some(ref doc) = lspitem.documentation {
-            info = doc.to_string();
-        } else {
-            info = "".to_string();
+            if !info.is_empty() {
+                info.push('\n');
+                info.push('\n');
+            }
+            info.push_str(doc.to_string().as_str());
         }
 
         VimCompleteItem {

9ary avatar Jun 02 '18 22:06 9ary

Is there a way of using NeoVim Virtual Text to help with this similar to #664? Maybe full signature arguments or just info for current argument?

Love the way diagnostics popup inline now, it'd be nice to get the signature help going as seamless

damienpontifex avatar Feb 24 '19 01:02 damienpontifex

I believe echodoc already supports the signature thing. I used that myself and am quite happy.

shuwens avatar Feb 25 '19 01:02 shuwens

Floating window is supposed to be merged soon (tomorrow or next week) https://github.com/neovim/neovim/pull/6619, would be nice to have support for preview with it.

teto avatar Mar 02 '19 11:03 teto

The floating window feature is merged :fireworks:

Related tweet: https://twitter.com/Neovim/status/1101879098044043264

wdv4758h avatar Mar 03 '19 05:03 wdv4758h

any updates on this?

luxmeter avatar Apr 26 '19 21:04 luxmeter

echodoc supports floating window. Screenshot from 2020-04-07 16-57-57

Kotaro7750 avatar Apr 07 '20 07:04 Kotaro7750

echodoc works fine in many cases. However, if you have an overloaded function, and you go to correct an already written function, it might show you the wrong overload.

Here it shows the help for foo with 3 parameters, but the code calls foo with 1 parameter.

image

Is it possible to give echodoc information about the overload through LanguageClient#textDocument_signatureHelp?
signatureHelp in clangd isn't perfect either, but somewhat better.

willir avatar Jul 26 '20 19:07 willir