Skip to content

Commit

Permalink
Move formatting to LSP store (#18242)
Browse files Browse the repository at this point in the history
Release Notes:

- ssh-remoting: Fixed format on save

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
  • Loading branch information
ConradIrwin and mikayla-maki authored Sep 23, 2024
1 parent e95e1c9 commit e4080ef
Show file tree
Hide file tree
Showing 8 changed files with 655 additions and 657 deletions.
2 changes: 1 addition & 1 deletion crates/activity_indicator/src/activity_indicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl ActivityIndicator {
}

// Show any formatting failure
if let Some(failure) = self.project.read(cx).last_formatting_failure() {
if let Some(failure) = self.project.read(cx).last_formatting_failure(cx) {
return Some(Content {
icon: Some(
Icon::new(IconName::Warning)
Expand Down
4 changes: 2 additions & 2 deletions crates/collab/src/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use live_kit_client::MacOSDisplay;
use lsp::LanguageServerId;
use parking_lot::Mutex;
use project::{
search::SearchQuery, search::SearchResult, DiagnosticSummary, FormatTrigger, HoverBlockKind,
Project, ProjectPath,
lsp_store::FormatTrigger, search::SearchQuery, search::SearchResult, DiagnosticSummary,
HoverBlockKind, Project, ProjectPath,
};
use rand::prelude::*;
use serde_json::json;
Expand Down
4 changes: 2 additions & 2 deletions crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ use ordered_float::OrderedFloat;
use parking_lot::{Mutex, RwLock};
use project::project_settings::{GitGutterSetting, ProjectSettings};
use project::{
CodeAction, Completion, CompletionIntent, FormatTrigger, Item, Location, Project, ProjectPath,
ProjectTransaction, TaskSourceKind,
lsp_store::FormatTrigger, CodeAction, Completion, CompletionIntent, Item, Location, Project,
ProjectPath, ProjectTransaction, TaskSourceKind,
};
use rand::prelude::*;
use rpc::{proto::*, ErrorExt};
Expand Down
4 changes: 2 additions & 2 deletions crates/editor/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use language::{
};
use multi_buffer::AnchorRangeExt;
use project::{
project_settings::ProjectSettings, search::SearchQuery, FormatTrigger, Item as _, Project,
ProjectPath,
lsp_store::FormatTrigger, project_settings::ProjectSettings, search::SearchQuery, Item as _,
Project, ProjectPath,
};
use rpc::proto::{self, update_view, PeerId};
use settings::Settings;
Expand Down
649 changes: 629 additions & 20 deletions crates/project/src/lsp_store.rs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions crates/project/src/prettier_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use smol::stream::StreamExt;
use util::{ResultExt, TryFutureExt};

use crate::{
worktree_store::WorktreeStore, File, FormatOperation, PathChange, ProjectEntryId, Worktree,
WorktreeId,
lsp_store::WorktreeId, worktree_store::WorktreeStore, File, PathChange, ProjectEntryId,
Worktree,
};

pub struct PrettierStore {
Expand Down Expand Up @@ -644,7 +644,7 @@ pub(super) async fn format_with_prettier(
prettier_store: &WeakModel<PrettierStore>,
buffer: &Model<Buffer>,
cx: &mut AsyncAppContext,
) -> Option<Result<FormatOperation>> {
) -> Option<Result<crate::lsp_store::FormatOperation>> {
let prettier_instance = prettier_store
.update(cx, |prettier_store, cx| {
prettier_store.prettier_instance_for_buffer(buffer, cx)
Expand All @@ -671,7 +671,7 @@ pub(super) async fn format_with_prettier(
let format_result = prettier
.format(buffer, buffer_path, cx)
.await
.map(FormatOperation::Prettier)
.map(crate::lsp_store::FormatOperation::Prettier)
.with_context(|| format!("{} failed to format buffer", prettier_description));

Some(format_result)
Expand Down
Loading

0 comments on commit e4080ef

Please sign in to comment.