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)).
This commit is contained in:
Flo 2024-03-01 10:22:43 +01:00 committed by GitHub
parent 34de33ef72
commit d6492d091d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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<LanguageServerBinary> {
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
})
}
}