Unnamed repository; edit this file 'description' to name the repository.
minor: Move json deserialization into text_document_hover future
This follows a pattern used in the signature help request for example. Moving the json deserialization into the return future of `text_document_hover` makes the types easier for callers to work with.
Michael Davis 12 months ago
parent 486f429 · commit fbc0f95
-rw-r--r--helix-lsp/src/client.rs5
-rw-r--r--helix-term/src/commands/lsp.rs6
2 files changed, 4 insertions, 7 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index d6308997..bf8a8695 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -1119,7 +1119,7 @@ impl Client {
text_document: lsp::TextDocumentIdentifier,
position: lsp::Position,
work_done_token: Option<lsp::ProgressToken>,
- ) -> Option<impl Future<Output = Result<Value>>> {
+ ) -> Option<impl Future<Output = Result<Option<lsp::Hover>>>> {
let capabilities = self.capabilities.get().unwrap();
// Return early if the server does not support hover.
@@ -1140,7 +1140,8 @@ impl Client {
// lsp::SignatureHelpContext
};
- Some(self.call::<lsp::request::HoverRequest>(params))
+ let res = self.call::<lsp::request::HoverRequest>(params);
+ Some(async move { Ok(serde_json::from_value(res.await?)?) })
}
// formatting
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index 1ef4d4bd..c5442924 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -1076,11 +1076,7 @@ pub fn hover(cx: &mut Context) {
.text_document_hover(doc.identifier(), pos, None)
.unwrap();
- async move {
- let json = request.await?;
- let response = serde_json::from_value::<Option<lsp::Hover>>(json)?;
- anyhow::Ok((server_name, response))
- }
+ async move { anyhow::Ok((server_name, request.await?)) }
})
.collect();