From 219d2c25156a496ed2923d4cef256352bb1302e5 Mon Sep 17 00:00:00 2001
From: PiergiorgioZagaria
Date: Thu, 4 Aug 2022 06:01:48 +0200
Subject: Change default formatter for any language (#2942)
* Change default formatter for any language
* Fix clippy error
* Close stdin for Stdio formatters
* Better indentation and pattern matching
* Return Result> for fn format instead of Option
* Remove unwrap for stdin
* Handle FormatterErrors instead of Result >
* Use Transaction instead of LspFormatting
* Use Transaction directly in Document::format
* Perform stdin type formatting asynchronously
* Rename formatter.type values to kebab-case
* Debug format for displaying io::ErrorKind (msrv fix)
* Solve conflict?
* Use only stdio type formatters
* Remove FormatterType enum
* Remove old comment
* Check if the formatter exited correctly
* Add formatter configuration to the book
* Avoid allocations when writing to stdin and formatting errors
* Remove unused import
Co-authored-by: Gokul Soumya ---
helix-term/src/commands.rs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'helix-term')
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index f12c79f9..7e757ce1 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -28,7 +28,7 @@ use helix_core::{
};
use helix_view::{
clipboard::ClipboardType,
- document::{Mode, SCRATCH_BUFFER_NAME},
+ document::{FormatterError, Mode, SCRATCH_BUFFER_NAME},
editor::{Action, Motion},
info::Info,
input::KeyEvent,
@@ -2471,14 +2471,14 @@ async fn make_format_callback(
doc_id: DocumentId,
doc_version: i32,
modified: Modified,
- format: impl Future + Send + 'static,
+ format: impl Future> + Send + 'static,
) -> anyhow::Result {
- let format = format.await;
+ let format = format.await?;
let call: job::Callback = Box::new(move |editor, _compositor| {
let view_id = view!(editor).id;
if let Some(doc) = editor.document_mut(doc_id) {
if doc.version() == doc_version {
- doc.apply(&Transaction::from(format), view_id);
+ doc.apply(&format, view_id);
doc.append_changes_to_history(view_id);
doc.detect_indent_and_line_ending();
if let Modified::SetUnmodified = modified {
--
cgit v1.2.3-70-g09d2