Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "lsp: Do not notify all language servers on file save" #19183

Conversation

WeetHet
Copy link
Contributor

@WeetHet WeetHet commented Oct 14, 2024

Reverts #17756. According to the existing implementations of the LSP specification, namely Helix and, if I'm not wrong, VSCode, textDocument/didSave has nothing to do with the watched files and should be sent to the language servers connected to the buffers even if the files are not watched by those. As the LSP spec doesn't say anything about didSave being related to the watched files, and the reference implementation in VSCode seemingly does not filter the notifications according to those, it seems like this is an incorrect interpretation of the specification

This also causes issues with language servers. See Metals issue for example

Closes #18636

Release Notes:

  • N/A

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 14, 2024
@zed-industries-bot
Copy link

zed-industries-bot commented Oct 14, 2024

Messages
📖

This PR includes links to the following GitHub Issues: #scalameta/metals-zed#28
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against aa5a59d

@WeetHet
Copy link
Contributor Author

WeetHet commented Oct 16, 2024

@osiewicz, no rush, but if you could tell me what the opinion of the team on this matter is, it would give me an idea of what to do next. I'm currently diving into Scala, and using another editor after Zed doesn't feel great 😔

@osiewicz
Copy link
Contributor

Hey, I am a bit busy right now, but I've marked myself as a reviewer as I was involved in both the original PR and the followup discussion.
From my POV, I don't mind either implementation, but do keep in mind that the original PR was intended to fix our integration with rust-analyzer; therefore, I don't think solving this issue is going to be as simple as reverting a PR. Basically, you either break Scala support or Rust support; one of them has to adjust (I don't think we should be special-casing our behavior depending on the server we're working on).

@tgodzik
Copy link

tgodzik commented Oct 16, 2024

Wasn't the Rust Analyzer actually fixed for that case? rust-lang/rust-analyzer@772acef

I will also try to reuse client file watching for .scala files once I have time to look at it, but since the assumptions are not really a LSP standard I am not sure if this will fix things with 100% certainty.

@osiewicz
Copy link
Contributor

@tgodzik yeah well, they've silenced the error so that it doesn't bring down the server. Still, it would be good (IMHO) to estabilish a common ground per this post.

@tgodzik
Copy link

tgodzik commented Oct 16, 2024

Wait, actually Rust Analyzer is doing the right thing, it's using https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentRegistrationOptions which has nothing to do with https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didChangeWatchedFiles

There actually is the specific option for didSave and if it's null then everything should be sent

@osiewicz
Copy link
Contributor

@tgodzik sweet, that settles it then. That means that Zed is the the one changing. I'll work up a PR to support filtering based on document selectors, as it seems like we don't have that at all right now.
Thank you for your persistence. I hope I didn't come across as too much of a PITA. :)

@tgodzik
Copy link

tgodzik commented Oct 16, 2024

I was mostly surprised, I haven't figured out the actual problem earlier. I did spend a lot of time in that spec already 😅 It made a lot of sense to have an option to declare supported files and it turns out there is!

@WeetHet
Copy link
Contributor Author

WeetHet commented Oct 16, 2024

I was mostly surprised, I haven't figured out the actual problem earlier. I did spend a lot of time in that spec already 😅 It made a lot of sense to have an option to declare supported files and it turns out there is!

Yeah, I somehow missed it too, even though I've seen it and had it in the back of my mind but for some reason the discussion in the LSP repo made me think otherwise

@osiewicz
Copy link
Contributor

@WeetHet since today is a release day and RA should not error too much after this revert, I'm going to merge your PR and work on a follow-up separately. Thanks!

@osiewicz osiewicz merged commit eddf70b into zed-industries:main Oct 16, 2024
12 checks passed
@WeetHet WeetHet deleted the revert-17756-lsp-do-not-notify-on-file-save branch October 16, 2024 11:58
noaccOS pushed a commit to noaccOS/zed that referenced this pull request Oct 19, 2024
…dustries#19183)

Reverts zed-industries#17756. According to the existing
implementations of the LSP specification, namely
[Helix](https://github.com/helix-editor/helix/blob/a7651f5bf027ec98645d571ab05a685d97e1b772/helix-view/src/document.rs#L1038)
and, if I'm not wrong,
[VSCode](https://github.com/microsoft/vscode-languageserver-node/blob/main/client/src/common/textSynchronization.ts#L580),
`textDocument/didSave` has nothing to do with the watched files and
should be sent to the language servers connected to the buffers even if
the files are not watched by those. As the LSP spec doesn't say anything
about `didSave` being related to the watched files, and the reference
implementation in VSCode seemingly does not filter the notifications
according to those, it seems like this is an incorrect interpretation of
the specification

This also causes issues with language servers. See [Metals
issue](scalameta/metals-zed#28 (comment))
for example

Closes zed-industries#18636

Release Notes:

- N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scala support broken in v0.156.x
4 participants