autozimu / LanguageClient-neovim

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

Preview window hover is broken #345

Closed YaLTeR closed 6 years ago

YaLTeR commented 6 years ago

I'm using an autocmd to call hover on CursorMove, and whenever it uses the preview window it acts very weirdly, preventing the further cursor movement and sometimes moving the cursor into the preview window.

Plug 'autozimu/LanguageClient-neovim', { \ 'branch': 'next', \ 'do': 'bash install.sh', \ }

call plug#end()

augroup filetype_rust autocmd! autocmd BufReadPost *.rs setlocal filetype=rust augroup END

let g:LanguageClient_serverCommands = { \ 'rust': ['rls'], \ } let g:LanguageClient_loggingLevel = 'DEBUG' let g:LanguageClient_autoStart = 1

" Automatic Hover let g:Plugin_LanguageClient_running = 0 augroup LanguageClient_config autocmd! autocmd User LanguageClientStarted let g:Plugin_LanguageClient_running = 1 autocmd User LanguageClientStopped let g:Plugin_LanguageClient_running = 0 autocmd CursorMoved .rs,.c,.cpp,.h,*.hpp if g:Plugin_LanguageClient_running | call LanguageClient_textDocument_hover() | endif augroup end


- Language server name/link and version RLS rls-preview 0.124.0-stable (299a6a9 2017-12-25)
- Reproduction steps (from clean state)
    1. Open some Rust file.
    2. Try stepping over something that produces a multi-line hover message.
- Logs. Ensure `let g:LanguageClient_loggingLevel = 'DEBUG'` is in minimal
  vimrc. Follow previous provided reproduction steps to reproduce the bug.
  Attach contents of `/tmp/LanguageClient.log` and `/tmp/LanguageServer.log`.
[LanguageClient.log](https://0x0.st/sBIO.log)
[LanguageServer.log](https://0x0.st/sBIV.log)
Shougo commented 6 years ago

I'm using an autocmd to call hover on CursorMove, and whenever it uses the preview window it acts very weirdly, preventing the further cursor movement and sometimes moving the cursor into the preview window.

I think the screencast is better.

For example: asciinema

YaLTeR commented 6 years ago

Good idea. Here's a recording: https://asciinema.org/a/7iW9jdi3M7YLXioDftbT9Ub64

When the cursor isn't moving and blinking between the preview and the main window — that's me trying to move the cursor normally.

Shougo commented 6 years ago

Oh, I see. It seems hover problem.

autozimu commented 6 years ago

It is caused by those lines https://github.com/autozimu/LanguageClient-neovim/blob/bbb92f5ebbebc44d5a3e2333f4b01d1eb92495e0/src/languageclient.rs#L557-L563

For neovim, there is an api to set buffer content directly, nvim_buf_set_lines(), but for vim, as far as I researched, there isn't a way to set buffer content without switching to it first.

autozimu commented 6 years ago

I will make a change to make use of this neovim API.

For vim though, it could be workarounded by writing the content to a tmp file and then use pedit to open the file. Definitely not ideal. There might be better ideas.

Shougo commented 6 years ago

For vim though, it could be workarounded by writing the content to a tmp file and then use pedit to open the file. Definitely not ideal. There might be better ideas.

For Vim8, I think you can use setbufline() instead. Note: 8.0.1039 is needed.

autozimu commented 6 years ago

Did I miss something? I believe setbufline() can only set content of current buffer.

Shougo commented 6 years ago

Did I miss something? I believe setbufline() can only set content of current buffer.

It is not only current buffer. For current buffer is setline().

setbufline({expr}, {lnum}, {text})          *setbufline()*
        Set line {lnum} to {text} in buffer {expr}.  To insert
        lines use |append()|.

        For the use of {expr}, see |bufname()| above.

        {lnum} is used like with |setline()|.
        This works like |setline()| for the specified buffer.
        On success 0 is returned, on failure 1 is returned.

        If {expr} is not a valid buffer or {lnum} is not valid, an
        error message is given.

I have tested setbufline() and it worked well.

autozimu commented 6 years ago

@Shougo Yeah, I did miss this part. Thanks.

YaLTeR commented 6 years ago

While we're at it I'd like to point out a couple of other issues:

autozimu commented 6 years ago

Thanks for pointing this out.

YaLTeR commented 6 years ago

Noticed one more thing: in visual select mode stepping over something that produces a multi-line hover cancels the selection. This doesn't happen with not multi-line hover.