autozimu / LanguageClient-neovim

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

Completion suggestions disappear when using with deoplete #795

Closed BenoitKnecht closed 5 years ago

BenoitKnecht commented 5 years ago

Describe the bug

I'm having trouble getting deoplete to work with autozimu/LanguageClient-neovim.

Specifically, I'm trying to get completion to work with Golang (using gopls as the language server). When I type something like fmt., I initially see a list of functions being suggested, but if I type a bit more (say fmt.Pri), the functions all disappear from the completion list (see the screencast below for an example of this).

I reported the issue agains deoplete, and the author was able to reproduce it but pin-pointed the issue in LanguageClient-neovim; he provided a patch as well, see Shougo/deoplete.nvim#970.

BenoitKnecht commented 5 years ago

For reference, here's the suggested patch:

diff --git a/src/types.rs b/src/types.rs
index b2d65bf..6eaac38 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -554,6 +554,9 @@ impl VimCompleteItem {
                     word = lspitem.label.clone();
                 }
             }
+            if word.is_empty() {
+                word = lspitem.label.clone();
+            }
         }

         let snippet;
autozimu commented 5 years ago

Thanks for reporting.

0xyeti commented 5 years ago

@autozimu I update LanguageClient-neovim to latest release, but the issue is still there. Can you reopen this?

Shougo commented 5 years ago

Your LanguageClient-neovim binary is the latest version?

0xyeti commented 5 years ago

Yes, its output version: languageclient 0.1.146 ec4af74cc389f802c3c43a660c963049848a8a93

BenoitKnecht commented 5 years ago

@0xyeti At first I thought it was weird because it works for me now, but I'm using a version of the binary I compiled myself with @Shougo's patch applied, and it looks like the fix that was committed in 6d0a8ee8bd414abb4e0b38e6207b5ea003066f32 is a bit different.

Shougo commented 5 years ago

Hm. The fix is not real fix?

0xyeti commented 5 years ago

@BenoitKnecht Yeah I've seen that too. I'll try to rebuild the binary from source, using Shougo's patch to see the error is still there or not.

sebastianst commented 5 years ago

@BenoitKnecht how did you configure LanguageClient to use gopls? Edit: Nevermind, it's as simple as

let g:LanguageClient_serverCommands = {
      \ 'go': ['~/go/bin/gopls'],
      \ }
BenoitKnecht commented 5 years ago

@sebastianst Here's the relevant part of my ~/.config/nvim/init.vim:

call plug#begin()
Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh' }
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
call plug#end()

let g:LanguageClient_serverCommands = { 'go': ['gopls'] }

let g:deoplete#enable_at_startup = 1

With the latest version of LanguageClient, it's almost working perfectly now. I get relevant suggestions, but when completing a function name, it completes all the way to the closing parenthesis, including the placeholder arguments, which is not what I expected. So if I type

fmt.Pri

and hit the completion shortcut, I get

fmt.Print(a ...interface{})

I'll open a new issue about that, but I'm again not sure if deoplete or LanguageClient is responsible.

Edit: @sebastianst I just noticed your edit, glad you figured it out :)

sebastianst commented 5 years ago

Thanks! BTW I can also confirm that f71ab82 solved the issue for me. And now I also have the same issue that you describe, the full function signature is completed.

sebastianst commented 5 years ago

This seems to be a LanguageClient issue as I don't have it with other completion sources like deoplete-jedi. @autozimu maybe reopen as your fix apparently introduced this new bug?

autozimu commented 5 years ago

The issue of completion full signature is that gopls return completion items of snippets, which this plugin isn't supporting well (yet).

The snippet completion support itself is complicated and I haven't have a clear path how to make it happen yet.

Some users has been reported success using ncm2, but I haven't tried it for quite some time.

wpaulino commented 5 years ago

Some users has been reported success using ncm2, but I haven't tried it for quite some time.

Can confirm I also have this issue with ncm2 and languageclient 0.1.146 6ee4c8994ee84609f8370aa4766b66c7cbad1424.

butterflyfish commented 5 years ago

I have the issue of completion full signature w/ latest ncm2 and languageclient. who should handle this issue, ncm2 or languageclient ?