windows: Fix `tailwind-language-server` (#17778)
Junkui Zhang
and
Anay
created 1 year ago
Closes #17741
I'm not sure why, but ever since `tailwind` was upgraded to `0.24`,
there have been occasional errors indicating that the `.ps1` file could
not be found. After reviewing the `.ps1` script, it appears that it
simply starts the server using `node`. This PR directly using the method
from the script to start the server with `node`.
Co-authored-by: Anay <me@anayparaswani.dev>
Release Notes:
- N/A
---------
Co-authored-by: Anay <me@anayparaswani.dev>
Change summary
crates/languages/src/tailwind.rs | 34 +++++++---------------------------
1 file changed, 7 insertions(+), 27 deletions(-)
Detailed changes
@@ -18,20 +18,15 @@ use std::{
use util::{maybe, ResultExt};
#[cfg(target_os = "windows")]
-const SERVER_PATH: &str = "node_modules/.bin/tailwindcss-language-server.ps1";
+const SERVER_PATH: &str =
+ "node_modules/@tailwindcss/language-server/bin/tailwindcss-language-server";
#[cfg(not(target_os = "windows"))]
const SERVER_PATH: &str = "node_modules/.bin/tailwindcss-language-server";
-#[cfg(not(target_os = "windows"))]
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
vec![server_path.into(), "--stdio".into()]
}
-#[cfg(target_os = "windows")]
-fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
- vec!["-File".into(), server_path.into(), "--stdio".into()]
-}
-
pub struct TailwindLspAdapter {
node: Arc<dyn NodeRuntime>,
}
@@ -114,26 +109,11 @@ impl LspAdapter for TailwindLspAdapter {
.await?;
}
- #[cfg(target_os = "windows")]
- {
- let env_path = self.node.node_environment_path().await?;
- let mut env = HashMap::default();
- env.insert("PATH".to_string(), env_path.to_string_lossy().to_string());
-
- Ok(LanguageServerBinary {
- path: "powershell.exe".into(),
- env: Some(env),
- arguments: server_binary_arguments(&server_path),
- })
- }
- #[cfg(not(target_os = "windows"))]
- {
- Ok(LanguageServerBinary {
- path: self.node.binary_path().await?,
- env: None,
- arguments: server_binary_arguments(&server_path),
- })
- }
+ Ok(LanguageServerBinary {
+ path: self.node.binary_path().await?,
+ env: None,
+ arguments: server_binary_arguments(&server_path),
+ })
}
async fn cached_server_binary(