aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp
diff options
context:
space:
mode:
authorJoe Neeman2021-06-23 18:35:39 +0000
committerBlaž Hrastnik2021-06-30 08:08:50 +0000
commitc9be480bf86489fbf659b45b107be0d26a076b50 (patch)
tree93272263cd449d39e40848788e036c07f122250f /helix-lsp
parent3007478567c45274e405ec3b57a273bfa0025cc9 (diff)
Make formatting happen asynchronously.
Diffstat (limited to 'helix-lsp')
-rw-r--r--helix-lsp/src/lib.rs16
1 files changed, 16 insertions, 0 deletions
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<lsp::TextEdit>,
+ pub offset_encoding: OffsetEncoding,
+ }
+
+ impl From<LspFormatting> for Transaction {
+ fn from(fmt: LspFormatting) -> Transaction {
+ generate_transaction_from_edits(&fmt.doc, fmt.edits, fmt.offset_encoding)
+ }
+ }
}
#[derive(Debug, PartialEq, Clone)]