autozimu / LanguageClient-neovim

Language Server Protocol (LSP) support for vim and neovim.
MIT License
3.55k stars 273 forks source link

Better display of signature help #196

Open phil-nelson opened 6 years ago

phil-nelson commented 6 years ago

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?

autozimu commented 6 years ago

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.

DerWeh commented 6 years ago

What jedi-vim does:

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

wsdjeg commented 6 years ago

@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 commented 6 years ago

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

MaskRay commented 6 years ago

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

chemzqm commented 6 years ago

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.

9ary commented 6 years ago

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 {
damienpontifex commented 5 years ago

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

shuwens commented 5 years ago

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

teto commented 5 years ago

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.

wdv4758h commented 5 years ago

The floating window feature is merged :fireworks:

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

luxmeter commented 5 years ago

any updates on this?

Kotaro7750 commented 4 years ago

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

willir commented 4 years ago

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.