dense-analysis / dense-analysis/ale
[LSP Completion Performance] Incremental sychronization (aka byte-ranges) and debounce `textDocument/didChange`
- Dominant language
- Vim Script
- Stars
- 14k
- Forks
- 1.5k
- Avg merge
- 17h 49m
- Merged PRs (30d)
- 1
Description
Hello ALE team,
This issue was invited by @w0rp in [this Reddit post](https://www.reddit.com/r/vim/comments/10mjx5p/dense_analysis_is_now_the_nonprofit_company_that/j8x6sz4/).
Firstly, I come from a position of ignorance about what strategy ALE currently uses with respect to LSP completion latency. If ALE already uses debouncing and byte-ranges, with respect to auto-completion, then please close this issue.
My history in the LSP space was firstly with the excellent [LSC](https://github.com/natebosch/vim-lsc) plugin and then to Neovim's native LSP client.
Initially Neovim's pure Lua LSP client performed worse than LSC (coded in Vimscript). Nate Bosch (LSC author) had implemented a very efficient client when it came to auto-completion performance; he debounced `didChange` events and in addition only sent byte-ranges to the Language Server. By contrast Neovim LSP (early on) did no debouncing and sent the full text buffer for each `didChange` event.
What is debouncing `didChange` events? Basically, when in insert mode (doing edits) don't send `didChange` until a pause longer than the debounce interval has occurred. In LSC's case that is 500ms as [noted here](https://github.com/natebosch/vim-lsc/blob/master/doc/lsc.txt#L232). The Neovim LSP discussion around debouncing is [noted here](https://github.com/neovim/neovim/pull/14119).
Closely related is the topic of byte-ranges; which are small snippets indicating the delta since the last `didChange` event. LSC has always used byte-ranges; Neovim LSP did not until I created [this issue](https://github.com/neovim/neovim/issues/13049) which then resulted in [this PR](https://github.com/neovim/neovim/issues/14093). It's a complex problem, but one that LSC already solved. Initally the Neovim team just used that LSC algorithm (with appropriate attribution). ALE could do the same thing, if incremental synchronization/byte-ranges are not currently employed.
The combination of byte-ranges (incremental synchronization) with debouncing proved hugely beneficial to auto-completion performance (with certain slower Language Servers). LSC already implements solutions, in Vimscript, to these issues. LSC is permissively licensed; Neovim did leverage the LSC algorithm.
Feel free to contemplate these suggestions, or to close if not applicable.
Best regards.
Contributor guide
Assessment
This issue has not been assessed yet.