diff --git a/crates/language/src/language_registry.rs b/crates/language/src/language_registry.rs index 4870c4ed53..918da4873f 100644 --- a/crates/language/src/language_registry.rs +++ b/crates/language/src/language_registry.rs @@ -860,7 +860,7 @@ impl LanguageRegistry { adapter: Arc, root_path: Arc, delegate: Arc, - cli_environment: Shared>>>, + project_environment: Shared>>>, cx: &mut AppContext, ) -> Option { let server_id = self.state.write().next_language_server_id(); @@ -881,7 +881,7 @@ impl LanguageRegistry { let task = cx.spawn({ let container_dir = container_dir.clone(); move |mut cx| async move { - let cli_environment = cli_environment.await; + let project_environment = project_environment.await; let binary_result = adapter .clone() @@ -892,15 +892,16 @@ impl LanguageRegistry { let mut binary = binary_result?; - // If this Zed project was opened from the CLI and the language server command itself + // If we do have a project environment (either by spawning a shell in in the project directory + // or by getting it from the CLI) and the language server command itself // doesn't have an environment (which it would have, if it was found in $PATH), then - // we pass along the CLI environment that we inherited. - if binary.env.is_none() && cli_environment.is_some() { + // we use the project environment. + if binary.env.is_none() && project_environment.is_some() { log::info!( - "using CLI environment for language server {:?}, id: {server_id}", + "using project environment for language server {:?}, id: {server_id}", adapter.name.0 ); - binary.env = cli_environment.clone(); + binary.env = project_environment.clone(); } let options = adapter diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index fb3d52eb9e..e1e6001d24 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -4646,7 +4646,7 @@ impl LspStore { let stderr_capture = Arc::new(Mutex::new(Some(String::new()))); let lsp_adapter_delegate = ProjectLspAdapterDelegate::for_local(self, worktree_handle, cx); - let cli_environment = local.environment.update(cx, |environment, cx| { + let project_environment = local.environment.update(cx, |environment, cx| { environment.get_environment(Some(worktree_id), Some(worktree_path.clone()), cx) }); @@ -4656,7 +4656,7 @@ impl LspStore { adapter.clone(), Arc::clone(&worktree_path), lsp_adapter_delegate.clone(), - cli_environment, + project_environment, cx, ) { Some(pending_server) => pending_server,