Skip to content

Problem parsing emacs initializing request #3123

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

Closed
samanpa opened this issue Feb 12, 2020 · 12 comments
Closed

Problem parsing emacs initializing request #3123

samanpa opened this issue Feb 12, 2020 · 12 comments

Comments

@samanpa
Copy link

samanpa commented Feb 12, 2020

RLS seems to be having issues converting the initializing message lsp_types::InitializeParams that it gets from my emacs installation.

The error it gets is Error("invalid type: null, expected a boolean", line: 0, column: 0).

Please find the gist below that contains the reproducer.
https://gist.github.com/samanpa/7bb31219b53e803e11cee26de8de7b1a

The error goes away when lsp-types is compiled without the proposed feature.

Problematic toml

[dependencies]
lsp-types = { version = "0.70", features = ["proposed"] }
serde = {version = "1.0", features = [ "derive" ]}
serde_json = "1.0"

Working toml

[dependencies]
lsp-types = { version = "0.70" }
serde = {version = "1.0", features = [ "derive" ]}
serde_json = "1.0"
@samanpa
Copy link
Author

samanpa commented Feb 12, 2020

Manually setting

"semanticHighlighting": null   

to true also fixes the issue. I guess it is more of a serde_json issue.

@matklad
Copy link
Member

matklad commented Feb 12, 2020

I think that was a bug in lsp-mode, which was fixed a while ago.

@samanpa
Copy link
Author

samanpa commented Feb 12, 2020

I have a smaller reproducer

use serde::{Deserialize, Serialize};

fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
    let value = serde_json::json!{
        {
            "semanticHighlightingCapabilities": {
                     "semanticHighlighting": null
                 }
        }
    };
    let res : TextDocumentClientCapabilities = serde_json::from_value(value)?;
    Ok(())
}

#[derive(Debug,  Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TextDocumentClientCapabilities {
    pub semantic_highlighting_capabilities: Option<SemanticHighlightingClientCapability>,
}

#[derive(Default, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SemanticHighlightingClientCapability {
    pub semantic_highlighting: bool,
}

Is serde_json not working correctly.

@samanpa
Copy link
Author

samanpa commented Feb 12, 2020

Never mind. It is an emacs bug.

@samanpa samanpa closed this as completed Feb 12, 2020
@mvaled
Copy link

mvaled commented May 8, 2020

@samanpa

Could you point us to the Emacs bug? I've updated my Emacs configuration and I'm getting a similar error while lsp-mode tries to run rust-analyzer.

@mvaled
Copy link

mvaled commented May 8, 2020

To answer my own question. lsp-mode.el is passing elisp's nil as null the variable in question is 'lsp-enable-semantic-highlighting'; but in Rust bool doesn't accept null values.

I worked around the issue by setting the variable to t.

@flodiebold
Copy link
Member

@mvaled That bug has been fixed since 4 months in lsp-mode, so I'd recommend updating.

@samanpa
Copy link
Author

samanpa commented May 9, 2020

Last I checked the change is not in melpa stable.

@mvaled
Copy link

mvaled commented May 11, 2020

I updated yesterday and now there's no variable lsp-enable-semantic-highlighting.

@matklad
Copy link
Member

matklad commented May 11, 2020 via email

@flodiebold
Copy link
Member

There's some support for some kind of semantic highlighting, but I'm not sure how well it works and whether it implements the current proposal (I guess I should try it out sometime). The variable got renamed to lsp-semantic-highlighting, I think.

@mvaled
Copy link

mvaled commented May 11, 2020

Yep. I can find lsp-semantic-highlighting which is nil by default...

I haven't read about semantic highlighting yet. I'll read about it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants