From 7162632eb739557ededaee902b23e48a577817b4 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Thu, 25 Feb 2021 18:07:47 +0900 Subject: lsp: Hover documentation draft. --- helix-lsp/src/client.rs | 58 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) (limited to 'helix-lsp/src') diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index b229cd1a..77e877e4 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -201,11 +201,12 @@ impl Client { context_support: None, // additional context information Some(true) ..Default::default() }), - // { completion: { - // dynamic_registration: bool - // completion_item: { snippet, documentation_format, ... } - // completion_item_kind: { } - // } } + hover: Some(lsp::HoverClientCapabilities { + // if not specified, rust-analyzer returns plaintext marked as markdown but + // badly formatted. + content_format: Some(vec![lsp::MarkupKind::Markdown]), + ..Default::default() + }), ..Default::default() }), ..Default::default() @@ -458,4 +459,51 @@ impl Client { Ok(items) } + + pub async fn text_document_signature_help( + &self, + text_document: lsp::TextDocumentIdentifier, + position: lsp::Position, + ) -> anyhow::Result> { + let params = lsp::SignatureHelpParams { + text_document_position_params: lsp::TextDocumentPositionParams { + text_document, + position, + }, + // TODO: support these tokens + work_done_progress_params: lsp::WorkDoneProgressParams { + work_done_token: None, + }, + context: None, + // lsp::SignatureHelpContext + }; + + let response = self + .request::(params) + .await?; + + Ok(response) + } + + pub async fn text_document_hover( + &self, + text_document: lsp::TextDocumentIdentifier, + position: lsp::Position, + ) -> anyhow::Result> { + let params = lsp::HoverParams { + text_document_position_params: lsp::TextDocumentPositionParams { + text_document, + position, + }, + // TODO: support these tokens + work_done_progress_params: lsp::WorkDoneProgressParams { + work_done_token: None, + }, + // lsp::SignatureHelpContext + }; + + let response = self.request::(params).await?; + + Ok(response) + } } -- cgit v1.2.3-70-g09d2