aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-12 07:20:56 +0000
committerBlaž Hrastnik2021-03-12 07:25:12 +0000
commit6cbfb050e2c99acf5cdfe7d981c262fbdeaf761c (patch)
tree5fb54d50d2cb0c72e62bea9b0ca52d0dc8c70d9c /helix-lsp
parentb7dd7310c44532f3e6e3154367100ee6520ca69b (diff)
lsp: Emit didSave notifications.
Diffstat (limited to 'helix-lsp')
-rw-r--r--helix-lsp/src/client.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index 40736f2b..ae858ce0 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -414,10 +414,29 @@ impl Client {
pub async fn text_document_did_save(
&self,
text_document: lsp::TextDocumentIdentifier,
+ text: &Rope,
) -> Result<()> {
+ let capabilities = self.capabilities.as_ref().unwrap(); // TODO: needs post init
+
+ let include_text = match &capabilities.text_document_sync {
+ Some(lsp::TextDocumentSyncCapability::Options(lsp::TextDocumentSyncOptions {
+ save: Some(options),
+ ..
+ })) => match options {
+ lsp::TextDocumentSyncSaveOptions::Supported(true) => false,
+ lsp::TextDocumentSyncSaveOptions::SaveOptions(lsp_types::SaveOptions {
+ include_text,
+ }) => include_text.unwrap_or(false),
+ // Supported(false)
+ _ => return Ok(()),
+ },
+ // unsupported
+ _ => return Ok(()),
+ };
+
self.notify::<lsp::notification::DidSaveTextDocument>(lsp::DidSaveTextDocumentParams {
text_document,
- text: None, // TODO:
+ text: include_text.then(|| text.into()),
})
.await
}