Omit tsdk_path from the servers' options if it does not exist (#23525)

Part of https://github.com/zed-industries/zed/issues/22606

Before, `tsdk_path` for vtsls and typescript-language-server
unconditionally set a `tsdk`/`tsserver` property for the corresponding
language server, even if there were no such directory at all.
Instead, make the corresponding code to omit such property if it was not
found on the FS.

Release Notes:

- Fixed "The path /.../tsserver.js doesn't point to a valid tsserver
install. Falling back to bundled TypeScript version." pop-up appearing
This commit is contained in:
Kirill Bulatov 2025-01-23 13:17:32 +02:00 committed by GitHub
parent d1be419fff
commit 91b0ca0895
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 92 additions and 19 deletions

View file

@ -25,6 +25,7 @@ use crate::language_settings::SoftWrap;
use anyhow::{anyhow, Context, Result};
use async_trait::async_trait;
use collections::{HashMap, HashSet};
use fs::Fs;
use futures::Future;
use gpui::{AppContext, AsyncAppContext, Model, SharedString, Task};
pub use highlight_map::HighlightMap;
@ -498,6 +499,7 @@ pub trait LspAdapter: 'static + Send + Sync {
/// Returns initialization options that are going to be sent to a LSP server as a part of [`lsp::InitializeParams`]
async fn initialization_options(
self: Arc<Self>,
_: &dyn Fs,
_: &Arc<dyn LspAdapterDelegate>,
) -> Result<Option<Value>> {
Ok(None)
@ -505,6 +507,7 @@ pub trait LspAdapter: 'static + Send + Sync {
async fn workspace_configuration(
self: Arc<Self>,
_: &dyn Fs,
_: &Arc<dyn LspAdapterDelegate>,
_: Arc<dyn LanguageToolchainStore>,
_cx: &mut AsyncAppContext,
@ -1901,6 +1904,7 @@ impl LspAdapter for FakeLspAdapter {
async fn initialization_options(
self: Arc<Self>,
_: &dyn Fs,
_: &Arc<dyn LspAdapterDelegate>,
) -> Result<Option<Value>> {
Ok(self.initialization_options.clone())