Stream: t-compiler/rust-analyzer

Topic: `initializationOptions` vs `workspace/configuration`


Martin Asquino (Oct 25 2020 at 19:58, on Zulip):

Sorry if this has been asked already or is clarified in the docs, I couldn't find anything clear enough for me.

I'm a little confused/unsure about what the server expects in both initializationOptions and workspace/configuration. Am I correct that given a settings.json file like this:

{
    "rust-analyzer": {
        "inlayHints": {
            "chainingHints": true
        }
    }
}

On initializationOptions it should send the object under the rust-analyzer section?

{
        "inlayHints": {
            "chainingHints": true
        }
    }

And the same if the server requests the section rust-analyzer via workspace/configuration ?

Basically, there would be no case where the whole contents of the file should be sent (the first JSON snippet).

I saw some issues opened on the repo for LSP that stated otherwise and that has made confused, is the above correct or am I interpreting things incorrectly here?

matklad (Oct 26 2020 at 10:51, on Zulip):

For init options, we expect exactly the same JSON as for getConfigration request: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#initializationoptions

matklad (Oct 26 2020 at 10:52, on Zulip):

The JSON indeed should be nested

matklad (Oct 26 2020 at 10:52, on Zulip):

How the JSON we see on the wire is mapped to settings in user's configuration is up to the editor. Some use nested json, some use foo.bar.baz style.

Jeremy Kolb (Oct 26 2020 at 13:36, on Zulip):

@Martin Asquino Did you see this https://github.com/rust-analyzer/rust-analyzer/blob/f0412da4a2c06e50030d13e37002d0440fc7cded/docs/dev/lsp-extensions.md#initializationoptions ? Do we need to make that more clear?

Martin Asquino (Oct 26 2020 at 14:03, on Zulip):

Ah no, I hadn't seen that! That is perfectly clear! Thanks both! :bow:

Last update: Jul 26 2021 at 13:45UTC