summaryrefslogtreecommitdiff
path: root/cli/lsp/config.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2020-12-07 21:46:39 +1100
committerGitHub <noreply@github.com>2020-12-07 21:46:39 +1100
commit301d3e4b6849d24154ac2d65c00a9b30223d000e (patch)
treeab3bc074493e6c9be8d1875233bc141bdc0da3b4 /cli/lsp/config.rs
parentc8e9b2654ec0d54c77bb3f49fa31c3986203d517 (diff)
feat: add mvp language server (#8515)
Resolves #8400
Diffstat (limited to 'cli/lsp/config.rs')
-rw-r--r--cli/lsp/config.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs
new file mode 100644
index 000000000..ebc145708
--- /dev/null
+++ b/cli/lsp/config.rs
@@ -0,0 +1,49 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
+use deno_core::error::AnyError;
+use deno_core::serde::Deserialize;
+use deno_core::serde_json;
+use deno_core::serde_json::Value;
+
+#[derive(Debug, Clone, Default)]
+pub struct ClientCapabilities {
+ pub status_notification: bool,
+}
+
+#[derive(Debug, Clone, Default, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct WorkspaceSettings {
+ pub enable: bool,
+ pub config: Option<String>,
+ pub import_map: Option<String>,
+ pub lint: bool,
+ pub unstable: bool,
+}
+
+#[derive(Debug, Clone, Default)]
+pub struct Config {
+ pub client_capabilities: ClientCapabilities,
+ pub settings: WorkspaceSettings,
+}
+
+impl Config {
+ pub fn update(&mut self, value: Value) -> Result<(), AnyError> {
+ let settings: WorkspaceSettings = serde_json::from_value(value)?;
+ self.settings = settings;
+ Ok(())
+ }
+
+ #[allow(clippy::redundant_closure_call)]
+ pub fn update_capabilities(
+ &mut self,
+ capabilities: &lsp_types::ClientCapabilities,
+ ) {
+ if let Some(experimental) = &capabilities.experimental {
+ let get_bool =
+ |k: &str| experimental.get(k).and_then(|it| it.as_bool()) == Some(true);
+
+ self.client_capabilities.status_notification =
+ get_bool("statusNotification");
+ }
+ }
+}