Fix prettier errors around Zed's settings.json/keymap.json files

Ports https://github.com/zed-industries/zed/pull/3191 to zed2

Deals with zed-industries/community#2191
Fix Zed starting too many prettier installations in the beginning, and not being able to format the config files.
This commit is contained in:
Kirill Bulatov 2023-10-31 12:26:49 +02:00
parent 88875fd006
commit 84c5494949
3 changed files with 113 additions and 28 deletions

View file

@ -44,6 +44,9 @@ pub const PRETTIER_SERVER_JS: &str = include_str!("./prettier_server.js");
const PRETTIER_PACKAGE_NAME: &str = "prettier";
const TAILWIND_PRETTIER_PLUGIN_PACKAGE_NAME: &str = "prettier-plugin-tailwindcss";
#[cfg(any(test, feature = "test-support"))]
pub const FORMAT_SUFFIX: &str = "\nformatted by test prettier";
impl Prettier {
pub const CONFIG_FILE_NAMES: &'static [&'static str] = &[
".prettierrc",
@ -60,9 +63,6 @@ impl Prettier {
".editorconfig",
];
#[cfg(any(test, feature = "test-support"))]
pub const FORMAT_SUFFIX: &str = "\nformatted by test prettier";
pub async fn locate(
starting_path: Option<LocateStart>,
fs: Arc<dyn Fs>,
@ -328,7 +328,7 @@ impl Prettier {
#[cfg(any(test, feature = "test-support"))]
Self::Test(_) => Ok(buffer
.update(cx, |buffer, cx| {
let formatted_text = buffer.text() + Self::FORMAT_SUFFIX;
let formatted_text = buffer.text() + FORMAT_SUFFIX;
buffer.diff(formatted_text, cx)
})?
.await),