aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/init.rs
diff options
context:
space:
mode:
authorVille Penttinen <[email protected]>2019-03-06 09:34:38 +0000
committerVille Penttinen <[email protected]>2019-03-06 09:34:38 +0000
commit0dcb1cb569417a17e27a4d8b34813ded41395268 (patch)
tree123896a906abdfb6de3c0e3f13e0c69e98e3cc01 /crates/ra_lsp_server/src/init.rs
parentce118da149a0db1815f188c9914001608a5ac09e (diff)
Add showWorkspaceLoadedNotification to vscode client
This allows users to control whether or not they want to see the "workspace loaded" notification. This is done on the server side using InitializationOptions which are provided by the client. By default show_workspace_loaded is true, meaning the notification is sent.
Diffstat (limited to 'crates/ra_lsp_server/src/init.rs')
-rw-r--r--crates/ra_lsp_server/src/init.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/crates/ra_lsp_server/src/init.rs b/crates/ra_lsp_server/src/init.rs
new file mode 100644
index 000000000..0b7a47a0b
--- /dev/null
+++ b/crates/ra_lsp_server/src/init.rs
@@ -0,0 +1,39 @@
1use serde::{Deserialize, Deserializer};
2
3/// Client provided initialization options
4#[derive(Deserialize, Clone, Copy, Debug)]
5#[serde(rename_all = "camelCase")]
6pub struct InitializationOptions {
7 /// Whether the client supports our custom highlighting publishing decorations.
8 /// This is different to the highlightingOn setting, which is whether the user
9 /// wants our custom highlighting to be used.
10 ///
11 /// Defaults to `true`
12 #[serde(default = "bool_true", deserialize_with = "nullable_bool_true")]
13 pub publish_decorations: bool,
14
15 /// Whether or not the workspace loaded notification should be sent
16 ///
17 /// Defaults to `true`
18 #[serde(default = "bool_true", deserialize_with = "nullable_bool_true")]
19 pub show_workspace_loaded: bool,
20}
21
22impl Default for InitializationOptions {
23 fn default() -> InitializationOptions {
24 InitializationOptions { publish_decorations: true, show_workspace_loaded: true }
25 }
26}
27
28fn bool_true() -> bool {
29 true
30}
31
32/// Deserializes a null value to a bool true by default
33fn nullable_bool_true<'de, D>(deserializer: D) -> Result<bool, D::Error>
34where
35 D: Deserializer<'de>,
36{
37 let opt = Option::deserialize(deserializer)?;
38 Ok(opt.unwrap_or(true))
39}