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

fix: LSP initialization options #1584

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

aldur
Copy link
Contributor

@aldur aldur commented Oct 15, 2024

Description

A client can send partial initialization options, e.g.:

require('clarinet') -- Adds clarinet LSP
lspconfig.clarinet.setup(extend_config({
    cmd = {'/run/current-system/sw/bin/bash', '/tmp/wrapper.sh'},
    init_options = {completion = true}
}))

When that happens, the deserialization from the following code would fail, because all other required fields of InitializationOptions would be missing.

LspRequest::Initialize(params) => {
let initialization_options = params
.initialization_options
.and_then(|o| serde_json::from_str(o.as_str()?).ok())
.unwrap_or(InitializationOptions::default());

This PR fixes that. In addition, it removes the unnecessary (I think) cast to string as we are already dealing with a serde_json::Value instance.

Breaking change?

No.

Example

See above.


Checklist

  • Tests added in this PR (if applicable). Note: I have tested it manually through nvim LSP. It would be good if someone using VSCode could test it as well.

@CLAassistant
Copy link

CLAassistant commented Oct 15, 2024

CLA assistant check
All committers have signed the CLA.

@hugocaillard hugocaillard self-requested a review October 15, 2024 15:55
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
components/clarity-lsp/src/common/backend.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@hugocaillard
Copy link
Collaborator

Tested in vscode and in zed as ac custom lsp.
It does make things better, thanks!

@hugocaillard hugocaillard merged commit 9948b1c into hirosystems:main Oct 17, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants