windows: Fix tailwindcss-language-server
(#13891)
We should run this server with `powershell`, or we will get some runtime errors.  Release Notes: - Fixed `tailwindcss-language-server` on Windows.
This commit is contained in:
parent
8f29ff8a63
commit
c22dbbebe2
1 changed files with 36 additions and 5 deletions
|
@ -18,6 +18,9 @@ use std::{
|
||||||
};
|
};
|
||||||
use util::{maybe, ResultExt};
|
use util::{maybe, ResultExt};
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
const SERVER_PATH: &str = "node_modules/.bin/tailwindcss-language-server.ps1";
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
const SERVER_PATH: &str = "node_modules/.bin/tailwindcss-language-server";
|
const SERVER_PATH: &str = "node_modules/.bin/tailwindcss-language-server";
|
||||||
|
|
||||||
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
|
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
|
||||||
|
@ -108,11 +111,39 @@ impl LspAdapter for TailwindLspAdapter {
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(LanguageServerBinary {
|
#[cfg(target_os = "windows")]
|
||||||
path: self.node.binary_path().await?,
|
{
|
||||||
env: None,
|
let mut env_path = vec![self
|
||||||
arguments: server_binary_arguments(&server_path),
|
.node
|
||||||
})
|
.binary_path()
|
||||||
|
.await?
|
||||||
|
.parent()
|
||||||
|
.expect("invalid node binary path")
|
||||||
|
.to_path_buf()];
|
||||||
|
|
||||||
|
if let Some(existing_path) = std::env::var_os("PATH") {
|
||||||
|
let mut paths = std::env::split_paths(&existing_path).collect::<Vec<_>>();
|
||||||
|
env_path.append(&mut paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
let env_path = std::env::join_paths(env_path)?;
|
||||||
|
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),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn cached_server_binary(
|
async fn cached_server_binary(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue