Skip to content

Commit

Permalink
typescript: Make it possible to use local vtsls (#15775)
Browse files Browse the repository at this point in the history
Related things:
#7902
#4978

Release Notes:
- Added: positibily to use locally installed vtsls
  • Loading branch information
kakoc authored Aug 6, 2024
1 parent d6e5265 commit f4a58e5
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion crates/languages/src/vtsls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use gpui::AsyncAppContext;
use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
use lsp::{CodeActionKind, LanguageServerBinary};
use node_runtime::NodeRuntime;
use project::project_settings::ProjectSettings;
use project::project_settings::{BinarySettings, ProjectSettings};
use serde_json::{json, Value};
use settings::Settings;
use std::{
Expand Down Expand Up @@ -69,6 +69,48 @@ impl LspAdapter for VtslsLspAdapter {
}) as Box<_>)
}

async fn check_if_user_installed(
&self,
delegate: &dyn LspAdapterDelegate,
cx: &AsyncAppContext,
) -> Option<LanguageServerBinary> {
let configured_binary = cx.update(|cx| {
ProjectSettings::get_global(cx)
.lsp
.get(SERVER_NAME)
.and_then(|s| s.binary.clone())
});

match configured_binary {
Ok(Some(BinarySettings {
path: Some(path),
arguments,
..
})) => Some(LanguageServerBinary {
path: path.into(),
arguments: arguments
.unwrap_or_default()
.iter()
.map(|arg| arg.into())
.collect(),
env: None,
}),
Ok(Some(BinarySettings {
path_lookup: Some(false),
..
})) => None,
_ => {
let env = delegate.shell_env().await;
let path = delegate.which(SERVER_NAME.as_ref()).await?;
Some(LanguageServerBinary {
path: path.clone(),
arguments: typescript_server_binary_arguments(&path),
env: Some(env),
})
}
}
}

async fn fetch_server_binary(
&self,
latest_version: Box<dyn 'static + Send + Any>,
Expand Down

0 comments on commit f4a58e5

Please sign in to comment.