Closed YaLTeR closed 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
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.
Oh, I see. It seems hover problem.
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.
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.
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.
Did I miss something? I believe setbufline()
can only set content of current buffer.
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.
@Shougo Yeah, I did miss this part. Thanks.
While we're at it I'd like to point out a couple of other issues:
\n
used to split the preview message seems to remain visible as ^@
(can be seen in the asciinema recording)2018-03-27T11:07:27.037201346+03:00 INFO languageclient::vim - => {"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":65,"line":52},"textDocument":{"uri":"file:///home/yalter/Source/rust/vapoursynth-rs/vapoursynth/src/plugins/mod.rs"}},"id":64}
2018-03-27T11:07:27.037659875+03:00 INFO languageclient::vim - <= {"jsonrpc":"2.0","id":64,"result":{"contents":[{"language":"rust","value":"unsafe extern \"system\" fn(identifier: *const c_char,\n defaultNamespace: *const c_char,\n name: *const c_char, apiVersion: c_int,\n readonly: c_int, plugin: *mut VSPlugin)"}],"range":null}}
2018-03-27T11:07:27.038670237+03:00 INFO languageclient::vim - => {"jsonrpc":"2.0","method":"execute","params":["echo 'unsafe extern \"system\" fn(identifier: *const c_char,\n defaultNamespace: *const c_char,\n name: *const c_char, apiVersion: c_int,\n readonly: c_int, plugin: *mut VSPlugin)'"]}
Thanks for pointing this out.
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.
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