ruff server: Support publish diagnostics as a fallback when pull diagnostics aren't supported#11092
Conversation
|
dhruvmanila
left a comment
There was a problem hiding this comment.
Thank you for implementing it so quickly!
Unless it's already done, we'd need to clear the diagnostics for the document for on_close event otherwise the diagnostics will remain in the "Problems" tab even after closing the file. Refer https://github.com/astral-sh/ruff-lsp/blob/187d7790be0783b9ac41ce025a724cf389bf575c/ruff_lsp/server.py#L459-L464
|
I think our old extension also had an option to pull diagnostics only on save. But I don't mind pushing this out until we're asked to build this (especially because we can't really support it when using pull diagnostics) |
|
@MichaReiser Are you referring to |
|
@dhruvmanila I've opened an issue (#11114) to solve the problem you mentioned earlier. |
|
As for the |
Summary
Fixes #11059
Several major editors don't support pull diagnostics, a method of sending diagnostics to the client that was introduced in version
0.3.17of the specification. Until now,ruff serverhas only used pull diagnostics, which resulted in diagnostics not being available on Neovim and Helix, which don't support pull diagnostics yet (though Neovim10.0will have support for this).ruff serverwill now utilize the older method of sending diagnostics, known as 'publish diagnostics', when pull diagnostics aren't supported by the client. This involves re-linting a document every time it is opened or modified, and then sending the diagnostics generated from that lint to the client via thetextDocument/publishDiagnosticsnotification.Test Plan
The easiest way to test that this PR works is to check if diagnostics show up on Neovim
<=0.9.