Skip to content

Commit 7551525

Browse files
committed
Add support to specifiy server name to send the correct initializationOptions
1 parent 797692c commit 7551525

7 files changed

+388
-42
lines changed

Cargo.lock

+71
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ thiserror = "1.0.20"
4242
lazy_static = "1.4.0"
4343
tracing = { version = "0.1", features = ["log", "log-always"] }
4444
tracing-log = "0.1.1"
45+
46+
[dev-dependencies]
47+
tempfile = "3.1.0"

doc/LanguageClient.txt

+26-1
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,34 @@ path this is relative to the workspace directory. If several paths are
231231
provided, then the corresponding settings are merged with precedence going to
232232
the last file.
233233

234+
The initialization options found in the files in this config are combined with
235+
the initialization options specified in the server command, if any. The former
236+
taking precedence over the latter.
237+
238+
Note that the key under which the initialization options for each server lives
239+
matches the key under which the server expects it's configuration. This is
240+
important for servers that can request configuration via a
241+
`workspace/configuration` request.
242+
243+
Previously, the initialization options lived under a `initializationOptions`
244+
key, which worked, but made answering that `workspace/configuration` request
245+
hard, since we couldn't really get the correct path to the setting the server
246+
requested. Since version 0.1.161 of this plugin, that key has been deprecated
247+
and you'll see a message saying that you should move off of it if your settings
248+
file includes an `initializationOptions` key.
249+
234250
Example settings file content: >
235251
{
236-
"rust.clippy_preference": "on"
252+
"gopls": {
253+
"usePlaceholders": true,
254+
"local": "github.com/my/pkg",
255+
},
256+
"rust-analyzer": {
257+
"inlayHints": {
258+
"enable": true,
259+
"chainingHints": true
260+
},
261+
},
237262
}
238263
239264
Default: ".vim/settings.json"

src/language_client.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ pub struct LanguageClient {
2121
}
2222

2323
impl LanguageClient {
24-
pub fn new(version: String, state: State) -> Self {
24+
pub fn new(version: impl Into<String>, state: State) -> Self {
2525
LanguageClient {
26-
version,
26+
version: version.into(),
2727
state_mutex: Arc::new(Mutex::new(state)),
2828
clients_mutex: Arc::new(Mutex::new(HashMap::new())),
2929
}

0 commit comments

Comments
 (0)