From d6492d091db954959e7e3eb22c37b3cf1820b032 Mon Sep 17 00:00:00 2001 From: Flo Date: Fri, 1 Mar 2024 10:22:43 +0100 Subject: [PATCH] Implement workspace_configuration for Dart LSP (#8568) This PR addressed https://github.com/zed-industries/zed/issues/8558 and allows the [Dart Client Workspace Configuration](https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration). Differing from the issue, the settings are used from the LSP settings section, example: ``` { "lsp": { "dart": { "settings": { "lineLength": 200 } } } } ``` Note: this only works for the global settings (not folder specific) Release Notes: - Fixed missing client workspace configuration of Dart LSP. Those can now be configured by setting `{"lsp": {"dart": { "settings: { "your-settings-here": "here"} } }` in the Zed settings. ([#8858](https://github.com/zed-industries/zed/issues/8558)). --- crates/languages/src/dart.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/languages/src/dart.rs b/crates/languages/src/dart.rs index 744e500615..bd906e67b1 100644 --- a/crates/languages/src/dart.rs +++ b/crates/languages/src/dart.rs @@ -1,8 +1,15 @@ use anyhow::{anyhow, Result}; use async_trait::async_trait; +use gpui::AppContext; use language::{LanguageServerName, LspAdapter, LspAdapterDelegate}; use lsp::LanguageServerBinary; -use std::{any::Any, path::PathBuf}; +use project::project_settings::ProjectSettings; +use serde_json::Value; +use settings::Settings; +use std::{ + any::Any, + path::{Path, PathBuf}, +}; pub struct DartLanguageServer; @@ -51,4 +58,16 @@ impl LspAdapter for DartLanguageServer { async fn installation_test_binary(&self, _: PathBuf) -> Option { None } + + fn workspace_configuration(&self, _workspace_root: &Path, cx: &mut AppContext) -> Value { + let settings = ProjectSettings::get_global(cx) + .lsp + .get("dart") + .and_then(|s| s.settings.clone()) + .unwrap_or_default(); + + serde_json::json!({ + "dart": settings + }) + } }