@@ -583,19 +583,19 @@ impl Client {
583583
584584 // formatting
585585
586− pub async fn text_document_formatting(
586+ pub fn text_document_formatting(
587587 &self,
588588 text_document: lsp::TextDocumentIdentifier,
589589 options: lsp::FormattingOptions,
590590 work_done_token: Option<lsp::ProgressToken>,
591− ) -> anyhow::Result<Vec<lsp::TextEdit>> {
591+ ) -> Option<impl Future<Output = Result<Vec<lsp::TextEdit>>>> {
592592 let capabilities = self.capabilities.get().unwrap();
593593
594594 // check if we're able to format
595595 match capabilities.document_formatting_provider {
596596 Some(lsp::OneOf::Left(true)) | Some(lsp::OneOf::Right(_)) => (),
597597 // None | Some(false)
598− _ => return Ok(Vec::new()),
598+ _ => return None,
599599 };
600600 // TODO: return err::unavailable so we can fall back to tree sitter formatting
601601
@@ -605,9 +605,13 @@ impl Client {
605605 work_done_progress_params: lsp::WorkDoneProgressParams { work_done_token },
606606 };
607607
608− let response = self.request::<lsp::request::Formatting>(params).await?;
608+ let request = self.call::<lsp::request::Formatting>(params);
609609
610− Ok(response.unwrap_or_default())
610+ Some(async move {
611+ let json = request.await?;
612+ let response: Vec<lsp::TextEdit> = serde_json::from_value(json)?;
613+ Ok(response)
614+ })
611615 }
612616
613617 pub async fn text_document_range_formatting(