nvim-lua / lsp-status.nvim

Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
MIT License
621 stars 41 forks source link

autocmd CursorHold stopped working #44

Open andrewrynhard opened 3 years ago

andrewrynhard commented 3 years ago

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.

wbthomason commented 3 years ago

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

wbthomason commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

wbthomason commented 3 years ago

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

wbthomason commented 3 years ago

@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 commented 3 years ago

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.

andrewrynhard commented 3 years ago

Thanks for digging into this @wbthomason.

andrewrynhard commented 3 years ago

Hmm, still not working for me FWIW.

wbthomason commented 3 years ago

@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.

joshuachp commented 3 years ago

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 commented 3 years ago

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 😅