Skip to content

Commit

Permalink
gd now works for singular definition
Browse files Browse the repository at this point in the history
  • Loading branch information
janhrastnik authored and archseer committed Mar 16, 2021
1 parent 18ec8ad commit 0322c28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 0 additions & 2 deletions helix-lsp/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0322c28

Please sign in to comment.