Closed willeccles closed 3 years ago
It's not possible to fix this without changing the LSP protocol. See here: https://github.com/microsoft/language-server-protocol/issues/737
The issue is that language servers send diagnostics to editors at any time and there's no real way to control when they arrive, as opposed to running a command on a file to check it, or the protocol TypeScript uses with tsserver
. Often using completion is the thing that triggers diagnostics being sent again. The protocol needs to be changed to offer an optional mode for servers where they don't send diagnostics unless the client requests them.
This doesn't make sense to me. I can have completion enabled and linting disabled and it (completion) works fine and does not cause linting on text changed. Why would it not be possible to use completion and only lint when the file is saved? It should work the same as when I disable linting but leave completion enabled.
The message for diagnostics from a language server isn't sent in response to any exact request, it is sent as a notification from the server to client, so you can't control when diagnostics will be received. They could come in response to asking for completion results because you told the server the document was changed, they could come completely at random. You could theoretically stash the list of diagnostics away and try and pass them on to be displayed only after some event has been triggered which a user has said they want results for, but it would be a complicated mess I don't want to devote any energy too.
The solution is to amend the Language Server Protocol so getting diagnostics can be controlled by the client.
Hm, I see. I quite dislike how that protocol works; it's very counter-intuitive. On a related note, how is it that disabling linting makes (neo)vim noticeably more responsive and less laggy if it's still receiving the same amount of data (and presumably parsing it)?
In the meantime, I think I will just add a hook for buffer writes that calls ALELint or whatever the command is. This is a decent middle-ground I think.
https://github.com/microsoft/vscode/issues/117042
The good news is that what I suggested is now a proposal under review, so it's probably only a matter of time until Language Server Protocol supports client control over diagnostics and this issue will slowly be resolved as more servers support it.
Hmm, it looks like they closed microsoft/vscode#117042. So it doesn't seem like they consider this pull model something that they're willing to implement?
Information
VIM version
NVIM v0.5.0-dev+nightly-1-g1f8de50-dirty Build type: Release
Operating System: I have experienced this on Linux (both Debian and Void) running in WSL and natively on macOS (all using exactly identical configs).
What went wrong
My configuration looks like this:
Reproducing the bug
When I write text in insert mode, ALE immediately updates all the time, which is causing noticeable latency when typing. However, this does not always happen. It seems to happen only sometimes and not others, and I can't find any patterns here.
Of course, I can get around this by disabling ALE and only invoking it manually, but this is quite painful compared to just having ALE lint when I write the buffer.
:ALEInfo