mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 06:05:19 +00:00
lsp: Do not cache initialization options
This commit is contained in:
parent
c209712b32
commit
3d1023ef52
2 changed files with 12 additions and 17 deletions
|
@ -113,7 +113,6 @@ pub struct LanguageServerName(pub Arc<str>);
|
||||||
pub struct CachedLspAdapter {
|
pub struct CachedLspAdapter {
|
||||||
pub name: LanguageServerName,
|
pub name: LanguageServerName,
|
||||||
pub short_name: &'static str,
|
pub short_name: &'static str,
|
||||||
pub initialization_options: Option<Value>,
|
|
||||||
pub disk_based_diagnostic_sources: Vec<String>,
|
pub disk_based_diagnostic_sources: Vec<String>,
|
||||||
pub disk_based_diagnostics_progress_token: Option<String>,
|
pub disk_based_diagnostics_progress_token: Option<String>,
|
||||||
pub language_ids: HashMap<String, String>,
|
pub language_ids: HashMap<String, String>,
|
||||||
|
@ -125,7 +124,6 @@ impl CachedLspAdapter {
|
||||||
pub async fn new(adapter: Arc<dyn LspAdapter>) -> Arc<Self> {
|
pub async fn new(adapter: Arc<dyn LspAdapter>) -> Arc<Self> {
|
||||||
let name = adapter.name().await;
|
let name = adapter.name().await;
|
||||||
let short_name = adapter.short_name();
|
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_diagnostic_sources = adapter.disk_based_diagnostic_sources().await;
|
||||||
let disk_based_diagnostics_progress_token =
|
let disk_based_diagnostics_progress_token =
|
||||||
adapter.disk_based_diagnostics_progress_token().await;
|
adapter.disk_based_diagnostics_progress_token().await;
|
||||||
|
@ -134,7 +132,6 @@ impl CachedLspAdapter {
|
||||||
Arc::new(CachedLspAdapter {
|
Arc::new(CachedLspAdapter {
|
||||||
name,
|
name,
|
||||||
short_name,
|
short_name,
|
||||||
initialization_options,
|
|
||||||
disk_based_diagnostic_sources,
|
disk_based_diagnostic_sources,
|
||||||
disk_based_diagnostics_progress_token,
|
disk_based_diagnostics_progress_token,
|
||||||
language_ids,
|
language_ids,
|
||||||
|
|
|
@ -2816,15 +2816,6 @@ impl Project {
|
||||||
let lsp = project_settings.lsp.get(&adapter.name.0);
|
let lsp = project_settings.lsp.get(&adapter.name.0);
|
||||||
let override_options = lsp.map(|s| s.initialization_options.clone()).flatten();
|
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 server_id = pending_server.server_id;
|
||||||
let container_dir = pending_server.container_dir.clone();
|
let container_dir = pending_server.container_dir.clone();
|
||||||
let state = LanguageServerState::Starting({
|
let state = LanguageServerState::Starting({
|
||||||
|
@ -2837,7 +2828,7 @@ impl Project {
|
||||||
let result = Self::setup_and_insert_language_server(
|
let result = Self::setup_and_insert_language_server(
|
||||||
this.clone(),
|
this.clone(),
|
||||||
&worktree_path,
|
&worktree_path,
|
||||||
initialization_options,
|
override_options,
|
||||||
pending_server,
|
pending_server,
|
||||||
adapter.clone(),
|
adapter.clone(),
|
||||||
language.clone(),
|
language.clone(),
|
||||||
|
@ -2958,7 +2949,7 @@ impl Project {
|
||||||
async fn setup_and_insert_language_server(
|
async fn setup_and_insert_language_server(
|
||||||
this: WeakModel<Self>,
|
this: WeakModel<Self>,
|
||||||
worktree_path: &Path,
|
worktree_path: &Path,
|
||||||
initialization_options: Option<serde_json::Value>,
|
override_initialization_options: Option<serde_json::Value>,
|
||||||
pending_server: PendingLanguageServer,
|
pending_server: PendingLanguageServer,
|
||||||
adapter: Arc<CachedLspAdapter>,
|
adapter: Arc<CachedLspAdapter>,
|
||||||
language: Arc<Language>,
|
language: Arc<Language>,
|
||||||
|
@ -2968,7 +2959,7 @@ impl Project {
|
||||||
) -> Result<Option<Arc<LanguageServer>>> {
|
) -> Result<Option<Arc<LanguageServer>>> {
|
||||||
let language_server = Self::setup_pending_language_server(
|
let language_server = Self::setup_pending_language_server(
|
||||||
this.clone(),
|
this.clone(),
|
||||||
initialization_options,
|
override_initialization_options,
|
||||||
pending_server,
|
pending_server,
|
||||||
worktree_path,
|
worktree_path,
|
||||||
adapter.clone(),
|
adapter.clone(),
|
||||||
|
@ -2998,7 +2989,7 @@ impl Project {
|
||||||
|
|
||||||
async fn setup_pending_language_server(
|
async fn setup_pending_language_server(
|
||||||
this: WeakModel<Self>,
|
this: WeakModel<Self>,
|
||||||
initialization_options: Option<serde_json::Value>,
|
override_options: Option<serde_json::Value>,
|
||||||
pending_server: PendingLanguageServer,
|
pending_server: PendingLanguageServer,
|
||||||
worktree_path: &Path,
|
worktree_path: &Path,
|
||||||
adapter: Arc<CachedLspAdapter>,
|
adapter: Arc<CachedLspAdapter>,
|
||||||
|
@ -3164,7 +3155,14 @@ impl Project {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.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?;
|
let language_server = language_server.initialize(initialization_options).await?;
|
||||||
|
|
||||||
language_server
|
language_server
|
||||||
|
|
Loading…
Reference in a new issue