aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hrastnik2021-02-23 22:56:06 +0000
committerBlaž Hrastnik2021-03-16 14:03:10 +0000
commit0322c28e6bc1f3bf13842b7db47aafbe5752d45c (patch)
tree1aab0291b3677b90d68c51feed14114827bd90b8
parent18ec8adc7f24d0cde3d185202f8656b5cf7fefb0 (diff)
gd now works for singular definition
-rw-r--r--helix-lsp/src/client.rs2
-rw-r--r--helix-term/src/commands.rs8
2 files changed, 8 insertions, 2 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index f3d3b7e1..e0005c09 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -603,8 +603,6 @@ impl Client {
let response = self.request::<lsp::request::GotoDefinition>(params).await?;
- println!("{:?}", response);
-
let items = match response {
Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
Some(lsp::GotoDefinitionResponse::Array(location_vec)) => location_vec,
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index fee4f362..b2809f96 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -861,6 +861,14 @@ pub fn goto_definition(cx: &mut Context) {
let res =
smol::block_on(language_server.goto_definition(doc.identifier(), pos)).unwrap_or_default();
+ if res.len() == 1 {
+ let definition_pos = res.get(0).unwrap().range.start;
+ let new_pos = helix_lsp::util::lsp_pos_to_pos(doc.text().slice(..), definition_pos);
+ doc.set_selection(Selection::point(new_pos));
+ } else {
+ // show menu picker i guess
+ }
+
doc.mode = Mode::Normal;
}