Open flwyd opened 8 months ago
It seems to be something with when a swap file is written. When I set
set updatetime=0
The float doesn't disappear until I write the file to disk. I think when I write the file to disk that is when the swap file is written as well.
I tried writing to disk with the default update time and the floating window stayed active, apart from a flicker. So I think it is something with writing a swap file and not the buffer's file.
I was facing the same issue. Seems like this may be related to the CursorHold
autocommand which fires after updatetime
milliseconds. From the vim-lsp
code this seems to be by design: https://github.com/prabirshrestha/vim-lsp/blob/f7ccf006df1aefd327c0e2c55cc8632a2db577c1/autoload/lsp/internal/diagnostics/float.vim#L20
:help updatetime
'updatetime' 'ut' number (default 4000)
global
If this many milliseconds nothing is typed the swap file will be
written to disk (see |crash-recovery|). Also used for the
|CursorHold| autocommand event.
Removing CursorHold
from the line above did not solve the issue but there are other calls to CursorHold
that might be removing floats
Somehow, my Vim seems to be also generating a CursorMove
event along with the CursorHold
event.
So just the removal of the CursorHold
from the list was not enough.
While trying to fix this exact issue I've changed a few things in this area, ultimately adding a configuration option to disable the "hide on CursorHold" behavior:
let g:lsp_diagnostics_float_hide_on_cursor_hold = 0
The first change in the series is posted for review.
If you want to get this functionality before the review process is done, you can apply this to your .vimrc
:
- Plug 'prabirshrestha/vim-lsp'
+ Plug 'ilya-bobyr/vim-lsp'
+ let g:lsp_diagnostics_float_hide_on_cursor_hold = 0
Or, maybe, be even more precise with the exact change you want:
- Plug 'prabirshrestha/vim-lsp'
+ Plug 'ilya-bobyr/vim-lsp', { 'commit': '61e72298180f7937cf5c141e6482ab9cbc64f3b9' }
+ let g:lsp_diagnostics_float_hide_on_cursor_hold = 0
It would also be nice to get someone else to try my changes. The event processing logic is somewhat tricky. While it does seem to work for me, there is a chance I broke an existing behavior others rely on.
Steps to reproduce:
echo "foo()\nbar()" > /tmp/foo.py
vim -u /tmp/minimal.vim /tmp/foo.py
undefined name 'foo'
in a popup window and in the status message. Both the window and the status disappear after a few seconds (maybe 5 seconds after moving the cursor?) and the status message becomes--No lines in buffer--
.Curiously, if
g:lsp_diagnostics_float_delay
is500
instead of2000
or1000
, the "No lines in buffer" message doesn't show up and the diagnostic status message stays in place, though the hover window still disappears after a few seconds. (Is the floating window supposed to disappear? I'd really like it to stay visible until I move the cursor.) 500 seems to be the magic value; anything larger results in "No lines in buffer" messages overwriting the status line while anything smaller doesn't.Contents of
/tmp/minimal.vim
, assumes vim-plug is already installed:This happens on the system vim for macOS 12.7 (9.0 with patches 1-1544), MacVim 9.0.1897, and a recent gvim on Debian Linux (9.0, don't have the patch list handy). It's not limited to any particular LSP; I've seen it with the Python and Julia LSPs from
vim-lsp-settings
as well as a company-internal LSP at work.