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

Refactor: Redraw as-needed #45

Closed wbthomason closed 3 years ago

wbthomason commented 3 years ago

This refactor builds on @joshuachp's timer-based design to offer (hopefully) the best of performance and simplicity. It refactors the redraw logic to be triggered when requested if it's been update_interval ms since the last redraw. This is in contrast to the every-update_interval ms check of the current design.

While the performance of these two designs is probably similar (this is at best a micro-optimization, though it should not be slower), I think this design is a bit simpler - we don't have to track the state of the needs_redraw flag, we don't eagerly generate the statusline text, etc.

We do still need a timer, but it runs at most once per redraw interval, and usually will not need to run. Its purpose is to account for redraws requested too close to the last redraw.

@joshuachp, what do you think? Does this branch still solve the performance issues of #36? Do you agree that this is simpler?

wbthomason commented 3 years ago

It's worth mentioning also that I've tested this to work with Sumneko Lua, rust-analyzer, JuliaLS, and pyright so far.

joshuachp commented 3 years ago

Seems perfect to me 👍🏻

wbthomason commented 3 years ago

@nerosnm, does this also maintain the fix to #36 for you? Since I was never able to reproduce #36, I'd like to get a couple of verifications that this still works as a fix.

nerosnm commented 3 years ago

@wbthomason I'll test this today and let you know

nerosnm commented 3 years ago

Still seems to be fine for me over the last few days

wbthomason commented 3 years ago

Great, thanks for testing. I think we're good to merge, then (famous last words...)