Refactor prettier (#17977)

In preparation for making formatting work on ssh remotes

Release Notes:

- N/A

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Conrad Irwin 2024-09-17 16:37:56 -06:00 committed by GitHub
parent db18f7a2b0
commit 8e45bf71ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 911 additions and 705 deletions

View file

@ -26,6 +26,7 @@ env_logger.workspace = true
fs.workspace = true
futures.workspace = true
gpui.workspace = true
node_runtime.workspace = true
log.workspace = true
project.workspace = true
remote.workspace = true

View file

@ -2,12 +2,13 @@ use anyhow::{anyhow, Result};
use fs::Fs;
use gpui::{AppContext, AsyncAppContext, Context, Model, ModelContext};
use language::{proto::serialize_operation, Buffer, BufferEvent, LanguageRegistry};
use node_runtime::DummyNodeRuntime;
use project::{
buffer_store::{BufferStore, BufferStoreEvent},
project_settings::SettingsObserver,
search::SearchQuery,
worktree_store::WorktreeStore,
LspStore, LspStoreEvent, ProjectPath, WorktreeId,
LspStore, LspStoreEvent, PrettierStore, ProjectPath, WorktreeId,
};
use remote::SshSession;
use rpc::{
@ -54,6 +55,16 @@ impl HeadlessProject {
buffer_store.shared(SSH_PROJECT_ID, session.clone().into(), cx);
buffer_store
});
let prettier_store = cx.new_model(|cx| {
PrettierStore::new(
DummyNodeRuntime::new(),
fs.clone(),
languages.clone(),
worktree_store.clone(),
cx,
)
});
let settings_observer = cx.new_model(|cx| {
let mut observer = SettingsObserver::new_local(fs.clone(), worktree_store.clone(), cx);
observer.shared(SSH_PROJECT_ID, session.clone().into(), cx);
@ -64,6 +75,7 @@ impl HeadlessProject {
let mut lsp_store = LspStore::new_local(
buffer_store.clone(),
worktree_store.clone(),
prettier_store.clone(),
environment,
languages.clone(),
None,