autozimu / LanguageClient-neovim

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

Disable CompleteDone for some language / Enable only for some #1135

Closed entropitor closed 3 years ago

entropitor commented 3 years ago

Describe the bug

I get the following error when completing an item using Neovim 0.5 builtin LSP and completion-nvim. I still need to install this plugin for https://github.com/ionide/Ionide-vim but that's only for fsharp. I don't want to break my setup for other languages

Error detected while processing function LanguageClient#handleCompleteDone:
line    2:
E691: Can only compare List with List
Error detected while processing function LanguageClient#handleCompleteDone:
line    2:
E15: Invalid expression: user_data ==# ''

It would be nice if this could be disabled.

Environment

martskins commented 3 years ago

Could you provide a log of the server responses? Setting LanguageClient_loggingLevel to DEBUG should given enough info. Also, a minimal reproducible example would help a lot (including .vimrc please).

And I'm not sure if it will have anything at that point, but if you could paste the output of :echo v:completed_item that'd be great!

martskins commented 3 years ago

If you feel like trying something out though, I think you won't have this issue in the dev branch, which has unreleased changes. As that branch has a commit that basically disables the autocmds for filetypes that you don't have a configured server for, so handleCompleteDone would be called only for fsharp. If you want to try that out you'll have to build from source though.

entropitor commented 3 years ago

Right now, I'm only installing this plugin for fsharp (using vim-plug for argument) and then doing the following to disable the CompleteDone

autocmd BufEnter *.fs,*.fsx,*.fsi autocmd! languageClient CompleteDone

It works for me but it's a bit annoying

This is :echo v:completed_item

{'word': 'string', 'menu': 'Microsoft.FSharp.Core.Operators.string', 'user_data': {'lsp': {'complet
ion_item': {'label': 'string', 'commitCharacters': [], 'data': {'FullName': 'Microsoft.FSharp.Core.
Operators.string'}, 'additionalTextEdits': [], 'insertText': 'string', 'kind': 2, 'detail': 'Micros
oft.FSharp.Core.Operators.string'}}}, 'info': ' ', 'kind': 'Method', 'abbr': 'string'}
martskins commented 3 years ago

Yeah I think this shouldn't be a problem for you in the dev branch. If you are happy to try that out it would be great. Otherwise, your fix seems like a reasonable approach until we cut the next release.

martskins commented 3 years ago

I'm actually a little surprised about the v:completed_item you get. The docs say this

All of these except "icase", "equal", "dup" and "empty" must be a string.  If
an item does not meet these requirements then an error message is given and
further items in the list are not used.  You can mix string and Dictionary
items in the returned list.

So theoretically user_data should be a string, not a dictionary. If it was a string, this wouldn't be a problem for you. So maybe it's worth opening an issue in completion-nvim. I'll see to do that later today.

martskins commented 3 years ago

Ok, turns out that that documentation is outdated, user_data can now be anything. I just merged a slightly related PR and included a fix for this. So it should work just fine for you in the dev branch now.

entropitor commented 3 years ago

Seems to work indeed!