From 986a516bf1237b343eb883c860019a692fb9a042 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 10 Oct 2023 17:16:43 +0300 Subject: [PATCH] Small style fixes --- crates/language/src/language.rs | 6 ++++++ crates/prettier/src/prettier.rs | 1 - crates/project/src/project.rs | 1 + crates/rpc/proto/zed.proto | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index c565d09c98..73906250f3 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -346,6 +346,12 @@ pub trait LspAdapter: 'static + Send + Sync { #[derive(Clone, Debug, PartialEq, Eq)] pub enum BundledFormatter { Prettier { + // See https://prettier.io/docs/en/options.html#parser for a list of valid values. + // Usually, every language has a single parser (standard or plugin-provided), hence `Some("parser_name")` can be used. + // There can not be multiple parsers for a single language, in case of a conflict, we would attempt to select the one with most plugins. + // + // But exceptions like Tailwind CSS exist, which uses standard parsers for CSS/JS/HTML/etc. but require an extra plugin to be installed. + // For those cases, `None` will install the plugin but apply other, regular parser defined for the language, and this would not be a conflict. parser_name: Option<&'static str>, plugin_names: Vec<&'static str>, }, diff --git a/crates/prettier/src/prettier.rs b/crates/prettier/src/prettier.rs index 5647123c75..07a7cbd73a 100644 --- a/crates/prettier/src/prettier.rs +++ b/crates/prettier/src/prettier.rs @@ -47,7 +47,6 @@ const PRETTIER_PACKAGE_NAME: &str = "prettier"; const TAILWIND_PRETTIER_PLUGIN_PACKAGE_NAME: &str = "prettier-plugin-tailwindcss"; impl Prettier { - // This was taken from the prettier-vscode extension. pub const CONFIG_FILE_NAMES: &'static [&'static str] = &[ ".prettierrc", ".prettierrc.json", diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 9a1d78f083..9dc3ff8758 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -8496,6 +8496,7 @@ impl Project { .insert(new_server_id, (name, Arc::clone(prettier_server))); // TODO kb could there be a race with multiple default prettier instances added? // also, clean up prettiers for dropped workspaces (e.g. external files that got closed) + // also, is there a way to speed up initial prettier startup? now it takes a 1s or so on the first formatting attempt. cx.emit(Event::LanguageServerAdded(new_server_id)); }); } diff --git a/crates/rpc/proto/zed.proto b/crates/rpc/proto/zed.proto index cbd334e334..aae207f41c 100644 --- a/crates/rpc/proto/zed.proto +++ b/crates/rpc/proto/zed.proto @@ -1574,8 +1574,8 @@ message PrettierInstanceForBufferResponse { message InvokePrettierForBuffer { uint64 project_id = 1; - optional uint64 buffer_id = 3; string prettier_path = 2; + optional uint64 buffer_id = 3; optional uint64 worktree_id = 4; string method = 5; }