Repository: autozimu/LanguageClient-neovim (language: rust)

Issue:
g:LanguageClient_hoverPreview='Always' does not play nicely with g:LanguageClient_useFloatingHover=1 if documentation is empty
- Did you upgrade to latest plugin version? Yes, running 12e65e7ce62ad769bd01a67063e82e4c01a839d6 (lattest commit on "next" branch).
- Did you upgrade to/compile latest binary? Run shell command
  `bin/languageclient --version` to get its version number: `languageclient 0.1.147 e4478a4789805c66ce24ae786677ae557cd411da`
- (Neovim users only) Did you check output of `:checkhealth LanguageClient`?

```
  1 health#LanguageClient#check
  2 ========================================================================
  3   - OK: binary found: /Users/glh/code/wincent/roles/dotfiles/files/.vim/pack/bundle/
      ↳ opt/LanguageClient-neovim/bin/languageclient
  4   - OK: languageclient 0.1.147 e4478a4789805c66ce24ae786677ae557cd411da
  5   - OK: Floating window is supported and will be used for hover
 ```

- Did you check [troubleshooting]? Yes

[troubleshooting]: https://github.com/autozimu/LanguageClient-neovim/blob/next/INSTALL.md#6-troubleshooting

## Describe the bug

With `let g:LanguageClient_hoverPreview='Always'` and `let g:LanguageClient_useFloatingHover=1`, calling `LanguageClient#textDocument_hover()` on a symbol with no documentation available will show an empty floating hover:

<img width="684" alt="Screen_Shot_2019-08-22_at_23_50_34_png" src="https://user-images.githubusercontent.com/7074/63552370-c5910700-c537-11e9-9f91-200b07b2e80f.png">

Normally you wouldn't notice this with (ie. with `let g:LanguageClient_hoverPreview='Auto'`, because missing documentation won't end up showing the floating hover.

I think the issue is likely here: https://github.com/autozimu/LanguageClient-neovim/blob/12e65e7ce62ad769bd01a67063e82e4c01a839d6/src/language_server_protocol.rs#L1045

It probably needs to check that the string is non-empty before doing anything.

## Environment
- neovim/vim version (`nvim --version` or `vim --version`):

```
NVIM v0.4.0-dev
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20190403-78663-17wqrlf/build/config -I/tmp/neovim-20190403-78663-17wqrlf/src -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/tmp/neovim-20190403-78663-17wqrlf/build/src/nvim/auto -I/tmp/neovim-20190403-78663-17wqrlf/build/include
Compiled by glh@retiro.local

Features: +acl +iconv +tui 
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-fb555c6/share/nvim"

Run :checkhealth for more info
```

- This plugin version (`git rev-parse --short HEAD`): `12e65e7ce62a`
- This plugin's binary version (`bin/languageclient --version`): `languageclient 0.1.147 e4478a4789805c66ce24ae786677ae557cd411da`
- Minimal vimrc content (A minimal vimrc is the smallest vimrc that could
  reproduce the issue. Refer to an example [here][min-vimrc.vim]):

```
let g:LanguageClient_useFloatingHover=1
let g:LanguageClient_hoverPreview='Always'
```

- Language server link and version: https://github.com/theia-ide/typescript-language-server (v0.3.8, ie. latest release), but as far as I know, it doesn't really matter which language server you use.

[min-vimrc.vim]: https://github.com/autozimu/LanguageClient-neovim/blob/next/min-vimrc.vim




Discussion / hints:
I thought this was by design, it's good to know that it's officially a bug!

The bigger problem is that this empty dialog can end up taking control of the input, and won't close automatically on keypress if you try closing it via non-standard means. (I have `<Esc>` mapped to `:noh<CR>:ccl<CR>:lclose<Esc>` to have it "reset" any interactive state.)

Fix patch:
diff --git a/src/language_server_protocol.rs b/src/language_server_protocol.rs
index faee09a5..bb5d4f63 100644
--- a/src/language_server_protocol.rs
+++ b/src/language_server_protocol.rs
@@ -1270,6 +1270,12 @@ impl LanguageClient {
 
         let hover = Option::<Hover>::deserialize(&result)?;
         if let Some(hover) = hover {
+            if hover.to_display().is_empty() {
+                self.vim()?
+                    .echowarn("No hover information found for symbol")?;
+                return Ok(Value::Null);
+            }
+
             let hover_preview = self.get(|state| state.hover_preview)?;
             let use_preview = match hover_preview {
                 HoverPreviewOption::Always => true,


Test patch: