lsp: Use project-local settings if available (#17753)

Release Notes:

- Changed built-in language support (Rust, Go, C, YAML, ...) to lookup
language-server specific settings locally in project directory first
before falling back to global value.

---------

Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
Thorsten Ball 2024-09-12 09:47:25 -04:00 committed by GitHub
parent 092f29d394
commit 9db68ee6ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 47 additions and 70 deletions

View file

@ -5,9 +5,9 @@ use gpui::AsyncAppContext;
use language::{ContextProvider, LanguageServerName, LspAdapter, LspAdapterDelegate};
use lsp::LanguageServerBinary;
use node_runtime::NodeRuntime;
use project::project_settings::ProjectSettings;
use project::lsp_store::language_server_settings;
use serde_json::Value;
use settings::Settings;
use std::{
any::Any,
borrow::Cow,
@ -177,13 +177,11 @@ impl LspAdapter for PythonLspAdapter {
async fn workspace_configuration(
self: Arc<Self>,
_: &Arc<dyn LspAdapterDelegate>,
adapter: &Arc<dyn LspAdapterDelegate>,
cx: &mut AsyncAppContext,
) -> Result<Value> {
cx.update(|cx| {
ProjectSettings::get_global(cx)
.lsp
.get(Self::SERVER_NAME)
language_server_settings(adapter.as_ref(), Self::SERVER_NAME, cx)
.and_then(|s| s.settings.clone())
.unwrap_or_default()
})