From 6cbfb050e2c99acf5cdfe7d981c262fbdeaf761c Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Fri, 12 Mar 2021 16:20:56 +0900 Subject: lsp: Emit didSave notifications. --- helix-lsp/src/client.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'helix-lsp/src') 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::DidSaveTextDocumentParams { text_document, - text: None, // TODO: + text: include_text.then(|| text.into()), }) .await } -- cgit v1.2.3-70-g09d2