@@ -583,19 +583,19 @@ impl Client {
584 // formatting
584 // formatting
586− pub async fn text_document_formatting(
586+ pub fn text_document_formatting(
588 text_document: lsp::TextDocumentIdentifier,
588 text_document: lsp::TextDocumentIdentifier,
589 options: lsp::FormattingOptions,
589 options: lsp::FormattingOptions,
590 work_done_token: Option<lsp::ProgressToken>,
590 work_done_token: Option<lsp::ProgressToken>,
591− ) -> anyhow::Result<Vec<lsp::TextEdit>> {
591+ ) -> Option<impl Future<Output = Result<Vec<lsp::TextEdit>>>> {
592 let capabilities = self.capabilities.get().unwrap();
592 let capabilities = self.capabilities.get().unwrap();
594 // check if we're able to format
594 // check if we're able to format
595 match capabilities.document_formatting_provider {
595 match capabilities.document_formatting_provider {
596 Some(lsp::OneOf::Left(true)) | Some(lsp::OneOf::Right(_)) => (),
596 Some(lsp::OneOf::Left(true)) | Some(lsp::OneOf::Right(_)) => (),
597 // None | Some(false)
597 // None | Some(false)
598− _ => return Ok(Vec::new()),
598+ _ => return None,
600 // TODO: return err::unavailable so we can fall back to tree sitter formatting
600 // TODO: return err::unavailable so we can fall back to tree sitter formatting
@@ -605,9 +605,13 @@ impl Client {
605 work_done_progress_params: lsp::WorkDoneProgressParams { work_done_token },
605 work_done_progress_params: lsp::WorkDoneProgressParams { work_done_token },
608− let response = self.request::<lsp::request::Formatting>(params).await?;
608+ let request = self.call::<lsp::request::Formatting>(params);
611+ let json = request.await?;
612+ let response: Vec<lsp::TextEdit> = serde_json::from_value(json)?;
610− Ok(response.unwrap_or_default())
613+ Ok(response)
613 pub async fn text_document_range_formatting(
617 pub async fn text_document_range_formatting(