-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
lsp: Do not notify all language servers on file save #17756
Conversation
This is not an ideal solution to https://github.com/fasterthanlime/zed-diags-readme, but current status quo is not great either; we were just going through all of the language servers and notifying them, whereas we should ideally do it based on a glob.
I do not fully understand this change nor exactly how the integration works, but I want to emphasize that rust analyzer should absolutely know about the change in the markdown file in this instance. The markdown file does contain rust code blocks that rust analyzer needs to know about I’m assuming. |
It's a bit more subtle; I don't think we spawn a separate language server instance in this case (for . md file) and the existing Rust instance does not care about Markdown files, as it does not register for watching of .md files. This is a can of worms. ૮꒰꩜ ᯅ ꩜;꒱ა |
Mhhh, I see. for the record the original error I saw in the logs was something like “got diagnostics for path/to/README.md but this path isn’t in VFS” or something. when making the repro I got a different error (the r-a panic) |
The panic in r-a happens because it receives an invalid path for the on save handler, it only registers rust and toml files for it but zed incorrectly gives it other files, violating the LSP (see #17376). We fixed panic behavior in r-a (it now logs an error) but this still needs fixing in zed. |
Okay but there is Rust code in the markdown file. The markdown file is included as the “doc” attribute of the .rs file, and there’s runnable doc tests in there, hence the diagnostics etc. Shouldn’t r-a care about this markdown file? |
I think there are 3 issues at play:
I think 1. is fully on Zed, no question asked; I'd say 2 is on RA side. Whether .md file contains Rust code or not seems orthogonal to the issue? |
Two things:
So to answer, yes, r-a should kind of care (in that it should track the content of the file changing), but it won't ever care about markdown files being saved. (there is a different notification for file updates that would be relevant). |
@osiewicz While the topic of Rust snippets in Markdown files seems more complex and would require further design and work, the changes in this PR still appear to make sense and be generally better than the current state of things. Would it make sense to go ahead and merge it, to avoid the most obvious issues and to improve the situation for all language servers (fix LSP violation)? 🙂 |
@filipwiech yeah agree, we should not creep the scope; I think the solution in this PR might actually undernotify in certain cases (e.g. I'm pretty sure it won't notify RA about changes to .toml files), so I'll hack on it some more on the plane today. |
…reee * origin/main: git blame gutter: Use smallest possible space (zed-industries#18145) Fix minimum gutter line number spacing (zed-industries#18021) terraform: Bump to v0.1.1 (zed-industries#18382) lsp: Do not notify all language servers on file save (zed-industries#17756) Remove leftover println statements (zed-industries#18389) Fix `use_on_type_format` setting being unused per language (zed-industries#18387) Avoid panic by only restoring workspace if UI has launched (zed-industries#18386) Fix Typo in rust language guide (zed-industries#18383) editor: Fix cursor shape not restoring when setting removed (zed-industries#18379) Avoid unwrap in file finder (zed-industries#18374)
@osiewicz Sorry to bother you, but it appears that this PR has broken support for Scala projects (with Scala extension, https://github.com/scalameta/metals-zed). After saving files with the Scala source code in the properly imported project LSP server doesn't get notified about the changes. AFAIK Metals (the LSP provider) does support the EDIT: Maybe the previous approach using the |
…ustries#17756)" This reverts commit db92a31.
Reverts #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 #18636 Release Notes: - N/A
…17756) This is not an ideal solution to https://github.com/fasterthanlime/zed-diags-readme, but current status quo is not great either; we were just going through all of the language servers and notifying them, whereas we should ideally do it based on a glob. /cc @fasterthanlime Release Notes: - N/A
…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
This is not an ideal solution to https://github.com/fasterthanlime/zed-diags-readme, but current status quo is not great either; we were just going through all of the language servers and notifying them, whereas we should ideally do it based on a glob.
/cc @fasterthanlime
Release Notes: