lsp-status.nvim icon indicating copy to clipboard operation
lsp-status.nvim copied to clipboard

autocmd CursorHold stopped working

Open andrewrynhard opened this issue 3 years ago • 12 comments

Hello 👋🏻 . I am coming back to nvim after some years away (never really was a power user) so forgive me if I am making a silly mistake. Really appreciate all that the Neovim community is doing lately with Lua. Feels great to get away from the heavy feeling of VScode.

Before #43 was merged the following autocmd worked:

autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics()

I could be missing something simple, but as far as I can tell (looking at a number of examples out there) there is nothing silly I am missing like my comment here.

andrewrynhard avatar Mar 28 '21 15:03 andrewrynhard

Thanks for the report! I can reproduce this issue, so some bug was introduced...

wbthomason avatar Mar 29 '21 16:03 wbthomason

Part of this is that the LspDiagnosticsChanged autocommand was removed, I think. I don't know why that would affect show_line_diagnostics, but it causes a stale diagnostics display in the statusline component at the least.

wbthomason avatar Mar 29 '21 17:03 wbthomason

Another interesting thing: If I manually trigger the show_line_diagnostics function, it works as expected, but the CursorHold autocommand doesn't seem to work for me. Maybe this is an issue with autocommand setup?

wbthomason avatar Mar 29 '21 17:03 wbthomason

Ah, and further if I run doautoall CursorHold things work as expected...

wbthomason avatar Mar 29 '21 17:03 wbthomason

Ok - for some reason, having the timer run prevents CursorHold from triggering.

wbthomason avatar Mar 29 '21 17:03 wbthomason

@andrewrynhard I think this is caused by https://github.com/neovim/neovim/issues/12587, which means that we need to rethink @joshuachp's timer-based design or have this plugin break CursorHold until that issue is closed.

wbthomason avatar Mar 29 '21 18:03 wbthomason

I've fixed the issue with LspDiagnosticsChanged not triggering a redraw. From discussion in the Neovim Gitter, there's a chance that https://github.com/neovim/neovim/issues/12587 can get fixed soon - if not, I'll spend some time looking at a redesign that gets around the need for a timer.

wbthomason avatar Mar 29 '21 18:03 wbthomason

Thanks for digging into this @wbthomason.

andrewrynhard avatar Mar 29 '21 18:03 andrewrynhard

Hmm, still not working for me FWIW.

andrewrynhard avatar Mar 29 '21 18:03 andrewrynhard

@andrewrynhard: right - as I said, we're blocked by https://github.com/neovim/neovim/issues/12587 and waiting for a bit to see if it gets fixed. The part I fixed is the diagnostics counts being displayed in the statusline component; CursorHold still has problems because of the linked upstream issue.

wbthomason avatar Mar 29 '21 18:03 wbthomason

I've fixed the issue with LspDiagnosticsChanged not triggering a redraw. From discussion in the Neovim Gitter, there's a chance that neovim/neovim#12587 can get fixed soon - if not, I'll spend some time looking at a redesign that gets around the need for a timer.

Sorry, I missed that. I thought it was an aucmd fired by the plugin.

joshuachp avatar Mar 29 '21 19:03 joshuachp

I was trying out an idea of stopping the timer when there is no update from the server. So the CursorHold shouldn't be blocked. Unfortunately I'm having some troubles with my LSP setup and didn't fully test it, but if you could perhaps try this branch solves the problem. joshuachp/lsp-status.nvim/stop-timer

I warn you, the code is awful and just for testing 😅

joshuachp avatar Mar 29 '21 19:03 joshuachp