mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
lsp: Do not cache initialization options
This commit is contained in:
parent
c209712b32
commit
3d1023ef52
@ -113,7 +113,6 @@ pub struct LanguageServerName(pub Arc<str>);
|
||||
pub struct CachedLspAdapter {
|
||||
pub name: LanguageServerName,
|
||||
pub short_name: &'static str,
|
||||
pub initialization_options: Option<Value>,
|
||||
pub disk_based_diagnostic_sources: Vec<String>,
|
||||
pub disk_based_diagnostics_progress_token: Option<String>,
|
||||
pub language_ids: HashMap<String, String>,
|
||||
@ -125,7 +124,6 @@ impl CachedLspAdapter {
|
||||
pub async fn new(adapter: Arc<dyn LspAdapter>) -> Arc<Self> {
|
||||
let name = adapter.name().await;
|
||||
let short_name = adapter.short_name();
|
||||
let initialization_options = adapter.initialization_options().await;
|
||||
let disk_based_diagnostic_sources = adapter.disk_based_diagnostic_sources().await;
|
||||
let disk_based_diagnostics_progress_token =
|
||||
adapter.disk_based_diagnostics_progress_token().await;
|
||||
@ -134,7 +132,6 @@ impl CachedLspAdapter {
|
||||
Arc::new(CachedLspAdapter {
|
||||
name,
|
||||
short_name,
|
||||
initialization_options,
|
||||
disk_based_diagnostic_sources,
|
||||
disk_based_diagnostics_progress_token,
|
||||
language_ids,
|
||||
|
@ -2816,15 +2816,6 @@ impl Project {
|
||||
let lsp = project_settings.lsp.get(&adapter.name.0);
|
||||
let override_options = lsp.map(|s| s.initialization_options.clone()).flatten();
|
||||
|
||||
let mut initialization_options = adapter.initialization_options.clone();
|
||||
match (&mut initialization_options, override_options) {
|
||||
(Some(initialization_options), Some(override_options)) => {
|
||||
merge_json_value_into(override_options, initialization_options);
|
||||
}
|
||||
(None, override_options) => initialization_options = override_options,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let server_id = pending_server.server_id;
|
||||
let container_dir = pending_server.container_dir.clone();
|
||||
let state = LanguageServerState::Starting({
|
||||
@ -2837,7 +2828,7 @@ impl Project {
|
||||
let result = Self::setup_and_insert_language_server(
|
||||
this.clone(),
|
||||
&worktree_path,
|
||||
initialization_options,
|
||||
override_options,
|
||||
pending_server,
|
||||
adapter.clone(),
|
||||
language.clone(),
|
||||
@ -2958,7 +2949,7 @@ impl Project {
|
||||
async fn setup_and_insert_language_server(
|
||||
this: WeakModel<Self>,
|
||||
worktree_path: &Path,
|
||||
initialization_options: Option<serde_json::Value>,
|
||||
override_initialization_options: Option<serde_json::Value>,
|
||||
pending_server: PendingLanguageServer,
|
||||
adapter: Arc<CachedLspAdapter>,
|
||||
language: Arc<Language>,
|
||||
@ -2968,7 +2959,7 @@ impl Project {
|
||||
) -> Result<Option<Arc<LanguageServer>>> {
|
||||
let language_server = Self::setup_pending_language_server(
|
||||
this.clone(),
|
||||
initialization_options,
|
||||
override_initialization_options,
|
||||
pending_server,
|
||||
worktree_path,
|
||||
adapter.clone(),
|
||||
@ -2998,7 +2989,7 @@ impl Project {
|
||||
|
||||
async fn setup_pending_language_server(
|
||||
this: WeakModel<Self>,
|
||||
initialization_options: Option<serde_json::Value>,
|
||||
override_options: Option<serde_json::Value>,
|
||||
pending_server: PendingLanguageServer,
|
||||
worktree_path: &Path,
|
||||
adapter: Arc<CachedLspAdapter>,
|
||||
@ -3164,7 +3155,14 @@ impl Project {
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
||||
let mut initialization_options = adapter.adapter.initialization_options().await;
|
||||
match (&mut initialization_options, override_options) {
|
||||
(Some(initialization_options), Some(override_options)) => {
|
||||
merge_json_value_into(override_options, initialization_options);
|
||||
}
|
||||
(None, override_options) => initialization_options = override_options,
|
||||
_ => {}
|
||||
}
|
||||
let language_server = language_server.initialize(initialization_options).await?;
|
||||
|
||||
language_server
|
||||
|
Loading…
Reference in New Issue
Block a user