aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp/src
diff options
context:
space:
mode:
authorJan Hrastnik2021-02-21 22:22:38 +0000
committerBlaž Hrastnik2021-03-16 14:03:10 +0000
commitd3ddc8dea6844f836199196c44b08e63fdf837d0 (patch)
treec8708cb3a4cad12392fc70991253ddb77f1a8f7f /helix-lsp/src
parentd8599f3a140eca7cd14f47e9b64f1ae9d829a0eb (diff)
wip
Diffstat (limited to 'helix-lsp/src')
-rw-r--r--helix-lsp/src/client.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index a9b7fe20..a747dc55 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -582,4 +582,43 @@ impl Client {
Ok(response.unwrap_or_default())
}
+
+ pub async fn goto_definition(
+ &self,
+ text_document: lsp::TextDocumentIdentifier,
+ position: lsp::Position,
+ ) -> anyhow::Result<Vec<lsp::Location>> {
+ let params = lsp::GotoDefinitionParams {
+ text_document_position_params: lsp::TextDocumentPositionParams {
+ text_document,
+ position,
+ },
+ work_done_progress_params: lsp::WorkDoneProgressParams {
+ work_done_token: None,
+ },
+ partial_result_params: lsp::PartialResultParams {
+ partial_result_token: None,
+ },
+ };
+
+ let response = self.request::<lsp::request::GotoDefinition>(params).await?;
+
+ let items = match response {
+ Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
+ Some(lsp::GotoDefinitionResponse::Array(location_vec)) => location_vec,
+ Some(lsp::GotoDefinitionResponse::Link(location_link_vec)) => {
+ let mut location_vec: Vec<lsp::Location> = Vec::new();
+ location_link_vec.into_iter().for_each(|location_link| {
+ let link = lsp::Location {
+ uri: location_link.target_uri,
+ range: location_link.target_range,
+ };
+ location_vec.append(&mut link);
+ });
+ location_vec
+ }
+ };
+
+ Ok(items)
+ }
}