microsoft / vscode-languageserver-node

Language server protocol implementation for VSCode. This allows implementing language services in JS/TS running on node.js
MIT License
1.48k stars 324 forks source link

ShowErrorMessage is spamming LanguageClient-neovim with message requests #507

Closed b0o closed 5 years ago

b0o commented 5 years ago

I've been experiencing a very odd behavior of ocaml-language-server + LanguageClient-neovim.

Messages such as the following appear when merlin has any sort of issue:

ocaml-langserver-bug

I have to dismiss 20+ of these messages by pressing enter repeatedly when this happens.

I've determined that this stems from ocaml-language-server calls vscode-langserver-node's showErrorMessage method defined here:

https://github.com/freebroccolo/ocaml-language-server/blob/6310438abaaad6b79175e3443e82437d2b91f1cd/src/bin/server/processes/merlin.ts#L41-L43

vscode-langserver-node then sends a LSP ShowMessageRequest message:

https://github.com/microsoft/vscode-languageserver-node/blob/58551741af1d90dd96d9c8a5b0069619884d8f22/server/src/main.ts#L837-L840

languageclient-neovim then handles this message:

https://github.com/autozimu/LanguageClient-neovim/blob/5491a64a07b259568e26981e5ec0d78ba8cec756/src/language_server_protocol.rs#L1862-L1883

... which finally calls from the Rust LSP client into the vimscript runtime code:

https://github.com/autozimu/LanguageClient-neovim/blob/0f171f5cef4f611bce3efc217fd83b021adbb3aa/autoload/LanguageClient.vim#L187-L192

which triggers the vim built-in function inputlist, as documented:

inputlist({textlist})                   *inputlist()*
        {textlist} must be a |List| of strings.  This |List| is
        displayed, one string per line.  The user will be prompted to
        enter a number, which is returned.
        The user can also select an item by clicking on it with the
        mouse.  For the first string 0 is returned.  When clicking
        above the first item a negative number is returned.  When
        clicking on the prompt one more than the length of {textlist}
        is returned.
        Make sure {textlist} has less than 'lines' entries, otherwise
        it won't work.  It's a good idea to put the entry number at
        the start of the string.  And put a prompt in the first item.
        Example: >
            let color = inputlist(['Select color:', '1. red',
                \ '2. green', '3. blue'])

inputlist basically displays the message (in this case an error message, not really a user input request message as it expects) as shown in the screenshot, which the user must then dismiss manually.

I am not sure as to which project is the culprit here, and thus where to file an issue, so I am opening this on all three projects.

b0o commented 5 years ago

Other issues: https://github.com/autozimu/LanguageClient-neovim/issues/859 https://github.com/freebroccolo/ocaml-language-server/issues/135

rcjsuen commented 5 years ago

Looks like this was changed a long time ago in 3e88fc32e8c232b7d00d27edf32621ac3a402ffd.

dbaeumer commented 5 years ago

The ShowMessageRequest is speced in the way that it waits for user input. See: https://microsoft.github.io/language-server-protocol/specification#window_showMessageRequest

I would rather argue that this is something the server needs to fix since the clients seems to work accordingly to the spec.

I close the issue. Please ping if you think otherwise.

rcjsuen commented 5 years ago

@dbaeumer I feel like the API needs to be clearer about this. If I'm just looking at the documentation of Show an error message., it's not at all clear that I'm asking for any user input here.

dbaeumer commented 5 years ago

Agree. Done on the server implementation.