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

lsp: Check for existing snapshots before sending off a didOpen notification #25409

Merged
merged 1 commit into from
Feb 23, 2025

Conversation

osiewicz
Copy link
Contributor

Closes #ISSUE

Release Notes:

  • Fixed Zed sending out didOpen notification to a language server when opening documents.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 22, 2025
@osiewicz osiewicz merged commit 918cba4 into main Feb 23, 2025
12 checks passed
@osiewicz osiewicz deleted the lsp-avoid-double-registration branch February 23, 2025 00:17
@osiewicz
Copy link
Contributor Author

/cherry-pick v0.175.x

gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Feb 23, 2025
…cation (#25409)

Closes #ISSUE

Release Notes:

- Fixed Zed sending out didOpen notification to a language server when
opening documents.
osiewicz added a commit that referenced this pull request Feb 23, 2025
…cation (cherry-pick #25409) (#25411)

Cherry-picked lsp: Check for existing snapshots before sending off a
didOpen notification (#25409)

Closes #ISSUE

Release Notes:

- Fixed Zed sending out didOpen notification to a language server when
opening documents.

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
@bajrangCoder
Copy link
Contributor

after this pr uno-language server starts to fails, as this name is undefined.
Previously it used to work.

@osiewicz
Copy link
Contributor Author

@bajrangCoder Thanks for reaching out and diagnosing the issue; this is probably unrelated to this PR as this one doesn't mess with server initialization anyhow.
If anything, #25337 would've "broke" it as a follow up to #24038
However, I don't think the fault is on our side, as the server you've linked:

  • Does not check for client capabilities for handling workspace folders in the first place (it only does so after accessing workspace folders).
  • Does not support dynamic registration of language servers (not their fault per se, but it renders them fundamentally incompatible with Zed with project: Fine-grained language server management #24038)
    I feel strongly that this is an issue that should be resolved upstream by fixing two of the points stated above.

Besides, they're also accessing.. name of the workspace folder? Not even the URI, which is what we fill out (we leave the name empty). This means that you could probably unconditionally run resolveDir function with either the name from the first workspace or some default (like "") if none is found. This feels to me like a relatively straightforward solution if you're willing to run your own fork.

@bajrangCoder
Copy link
Contributor

Thanks for your help!

Btw, I apologize for mistakenly disturbing the wrong PR.

I also came across several strange issues in the server and also some missing stuffs, which is why I started implementing my own from scratch. However, due to my exams, the development is currently on hold, but I plan to resume it once they are over.

Actually, a user reported an issue on zed-unocss, mentioning that the extension fails to start the LSP server on Zed 0.175.3 Preview. That’s why I thought something might have changed in Zed.

@osiewicz
Copy link
Contributor Author

Don't worry, it's okay to ping as long as it's at least somewhat related. :) And yeah, Zed changes broke it, but I'd say that the changes we made are reasonable and the language server for unocss is the odd one out.

@tuzemec
Copy link

tuzemec commented Feb 26, 2025

I've created a PR to the unocss-language-server that I hope resolves the first issue.

But I'm not sure how to approach the dynamic registration part. Is there some documentation that I can check? I can't quite figure what's happening in #24038 (maybe it's about time to learn some rust...).

@osiewicz
Copy link
Contributor Author

osiewicz commented Feb 26, 2025

Oh, sorry, my wording was a bit imprecise:

Does not support dynamic registration of language servers (not their fault per se, but it renders them fundamentally incompatible with Zed with #24038)
I feel strongly that this is an issue that should be resolved upstream by fixing two of the points stated above.

It should've said dynamic registration of workspace folders. Previously we've always had only one workspace folder per workspace, which we provided on server initialization and we never updated the list (there can be multiple workspace folders per project).
#24038 changed that. Language server protocol allows us to report workspace folders on the fly via DidChangeWorkspaceFolders notification - the server has to support it though, and unocss does not do that.

Honestly your PR looks good to me. It'll make unocss work just as well as prior to #24038. #24038 is really about improving language server support in large projects, e.g. monorepos.

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.

3 participants