diff --git a/crates/prettier/prettier_server/.gitignore b/crates/prettier/prettier_server/.gitignore deleted file mode 100644 index c2658d7d1b..0000000000 --- a/crates/prettier/prettier_server/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules/ diff --git a/crates/prettier/prettier_server/.zed/settings.json b/crates/prettier/prettier_server/.zed/settings.json deleted file mode 100644 index 856536c62d..0000000000 --- a/crates/prettier/prettier_server/.zed/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "languages": { - "JavaScript": { - "tab_size": 4 - } - } -} diff --git a/crates/prettier/prettier_server/package-lock.json b/crates/prettier/prettier_server/package-lock.json deleted file mode 100644 index 01fd75f3dd..0000000000 --- a/crates/prettier/prettier_server/package-lock.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "prettier_server", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "prettier_server", - "version": "1.0.0" - } - } -} diff --git a/crates/prettier/prettier_server/package.json b/crates/prettier/prettier_server/package.json deleted file mode 100644 index a591a37bdb..0000000000 --- a/crates/prettier/prettier_server/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "prettier_server", - "version": "1.0.0", - "description": "", - "main": "src/index.js", - "scripts": { - "start": "node src/index.js", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Zed Industries", - "dev-dependencies": { - "prettier": "^3.0" - } -} diff --git a/crates/prettier/src/prettier.rs b/crates/prettier/src/prettier.rs index d68af349d9..e5b001f226 100644 --- a/crates/prettier/src/prettier.rs +++ b/crates/prettier/src/prettier.rs @@ -18,6 +18,8 @@ pub struct LocateStart { pub starting_path: Arc, } +pub const PRETTIER_SERVER_JS: &str = include_str!("./prettier_server.js"); + impl Prettier { // This was taken from the prettier-vscode extension. pub const CONFIG_FILE_NAMES: &'static [&'static str] = &[ diff --git a/crates/prettier/prettier_server/src/index.js b/crates/prettier/src/prettier_server.js similarity index 100% rename from crates/prettier/prettier_server/src/index.js rename to crates/prettier/src/prettier_server.js diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index ffc15ee0d3..b3d00afd8a 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -79,7 +79,7 @@ use std::{ time::{Duration, Instant}, }; use terminals::Terminals; -use text::Anchor; +use text::{Anchor, LineEnding, Rope}; use util::{ debug_panic, defer, http::HttpClient, @@ -8350,10 +8350,10 @@ impl Project { let fs = Arc::clone(&self.fs); cx.background() .spawn(async move { - let prettier_dir_metadata = fs.metadata(default_prettier_dir).await.with_context(|| format!("fetching FS metadata for prettier default dir {default_prettier_dir:?}"))?; - if prettier_dir_metadata.is_none() { - fs.create_dir(default_prettier_dir).await.with_context(|| format!("creating prettier default dir {default_prettier_dir:?}"))?; - } + let prettier_wrapper_path = default_prettier_dir.join("prettier_server.js"); + // method creates parent directory if it doesn't exist + fs.save(&prettier_wrapper_path, &Rope::from(prettier::PRETTIER_SERVER_JS), LineEnding::Unix).await + .with_context(|| format!("writing prettier_server.js file at {prettier_wrapper_path:?}"))?; let packages_to_versions = future::try_join_all( prettier_plugins