autozimu / LanguageClient-neovim

Language Server Protocol (LSP) support for vim and neovim.
MIT License
3.55k stars 273 forks source link

Debounce CursorMoved handler #1152

Closed martskins closed 3 years ago

martskins commented 3 years ago

This PR debounces the handling of CursorMoved as not to spam the client with unnecessary calls. Note that this uses timer_start which I believe is available from vim 7.4, but it may not be available in some builds, so I included a sort of polyfill for timer_stop and timer_start which will at least run the function ignoring the timer functionality.

I also had to add a check on LanguageClient#handleCompleteChanged for the existence of timer_start, since we use it to prevent running into the textlock issue. There's probably another way to avoid that, but I'm not sure what that is now.