aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hrastnik2021-03-10 22:35:12 +0000
committerBlaž Hrastnik2021-03-16 14:03:10 +0000
commita5f9080a9cbc765758ce8af0c19a970a05745c60 (patch)
tree171206628ed8a6670ba78a8797b48884870d3fe3
parent3869d7713e2dfd2621f7e5a656ebac0b13d10542 (diff)
goto_request wip
-rw-r--r--Cargo.lock1
-rw-r--r--helix-lsp/src/client.rs43
2 files changed, 22 insertions, 22 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ac1f172a..5fac3391 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -550,7 +550,6 @@ dependencies = [
"helix-view",
"ignore",
"log",
- "lsp-types",
"num_cpus",
"once_cell",
"pulldown-cmark",
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index cd07699d..9c315272 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -583,10 +583,26 @@ impl Client {
Ok(response.unwrap_or_default())
}
- pub async fn goto_generic(
+ pub async fn goto_request<T: lsp::request::Request>(
&self,
- response: Option<lsp::GotoDefinitionResponse>,
+ 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::<T>(params).await?;
+
let items = match response {
Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
Some(lsp::GotoDefinitionResponse::Array(location_vec)) => location_vec,
@@ -612,22 +628,7 @@ impl Client {
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?;
-
- self.goto_generic(response).await
+ self.goto_request(response).await
}
pub async fn goto_type_definition(
@@ -652,7 +653,7 @@ impl Client {
.request::<lsp::request::GotoTypeDefinition>(params)
.await?;
- self.goto_generic(response).await
+ self.goto_request(response).await
}
pub async fn goto_implementation(
@@ -677,7 +678,7 @@ impl Client {
.request::<lsp::request::GotoImplementation>(params)
.await?;
- self.goto_generic(response).await
+ self.goto_request(response).await
}
pub async fn goto_reference(
@@ -703,7 +704,7 @@ impl Client {
let response = self.request::<lsp::request::References>(params).await?;
- self.goto_generic(response.map(lsp::GotoDefinitionResponse::Array))
+ self.goto_request(response.map(lsp::GotoDefinitionResponse::Array))
.await
}
}