Enable css, json and tailwind to lookup LSP installed in PATH

This commit is contained in:
Henry Chu 2024-12-15 17:43:24 +08:00
parent f64fcedabb
commit 3ec3ec3fda
No known key found for this signature in database
GPG key ID: 8B74A8C237C10C06
3 changed files with 54 additions and 1 deletions

View file

@ -1,7 +1,8 @@
use anyhow::{anyhow, Result};
use async_trait::async_trait;
use futures::StreamExt;
use language::{LspAdapter, LspAdapterDelegate};
use gpui::AsyncAppContext;
use language::{LanguageToolchainStore, LspAdapter, LspAdapterDelegate};
use lsp::{LanguageServerBinary, LanguageServerName};
use node_runtime::NodeRuntime;
use serde_json::json;
@ -37,6 +38,24 @@ impl LspAdapter for CssLspAdapter {
LanguageServerName("vscode-css-language-server".into())
}
async fn check_if_user_installed(
&self,
delegate: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext,
) -> Option<LanguageServerBinary> {
let path = delegate
.which("vscode-css-language-server".as_ref())
.await?;
let env = delegate.shell_env().await;
Some(LanguageServerBinary {
path,
env: Some(env),
arguments: vec!["--stdio".into()],
})
}
async fn fetch_latest_server_version(
&self,
_: &dyn LspAdapterDelegate,

View file

@ -136,6 +136,24 @@ impl LspAdapter for JsonLspAdapter {
LanguageServerName("json-language-server".into())
}
async fn check_if_user_installed(
&self,
delegate: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext,
) -> Option<LanguageServerBinary> {
let path = delegate
.which("vscode-json-language-server".as_ref())
.await?;
let env = delegate.shell_env().await;
Some(LanguageServerBinary {
path,
env: Some(env),
arguments: vec!["--stdio".into()],
})
}
async fn fetch_latest_server_version(
&self,
_: &dyn LspAdapterDelegate,

View file

@ -46,6 +46,22 @@ impl LspAdapter for TailwindLspAdapter {
Self::SERVER_NAME.clone()
}
async fn check_if_user_installed(
&self,
delegate: &dyn LspAdapterDelegate,
_: Arc<dyn LanguageToolchainStore>,
_: &AsyncAppContext,
) -> Option<LanguageServerBinary> {
let path = delegate.which(Self::SERVER_NAME.as_ref()).await?;
let env = delegate.shell_env().await;
Some(LanguageServerBinary {
path,
env: Some(env),
arguments: vec!["--stdio".into()],
})
}
async fn fetch_latest_server_version(
&self,
_: &dyn LspAdapterDelegate,