From c9be480bf86489fbf659b45b107be0d26a076b50 Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Wed, 23 Jun 2021 13:35:39 -0500 Subject: Make formatting happen asynchronously. --- helix-lsp/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'helix-lsp') diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index e4ab153c..96a45bb9 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -182,6 +182,22 @@ pub mod util { }), ) } + + /// The result of asking the language server to format the document. This can be turned into a + /// `Transaction`, but the advantage of not doing that straight away is that this one is + /// `Send` and `Sync`. + #[derive(Clone, Debug)] + pub struct LspFormatting { + pub doc: Rope, + pub edits: Vec, + pub offset_encoding: OffsetEncoding, + } + + impl From for Transaction { + fn from(fmt: LspFormatting) -> Transaction { + generate_transaction_from_edits(&fmt.doc, fmt.edits, fmt.offset_encoding) + } + } } #[derive(Debug, PartialEq, Clone)] -- cgit v1.2.3-70-g09d2