gd now works for singular definition
commit0322c28e6bc1f3bf13842b7db47aafbe5752d45c
authorJan Hrastnik <jan.hrastnik2@gmail.com>
dateTue 23 Feb 2021, 23:56 (6 years ago)
parent18ec8ad
helix-lsp/src/client.rs−2
@@ -603,8 +603,6 @@ impl Client {
603603
604604 let response = self.request::<lsp::request::GotoDefinition>(params).await?;
605605
606− println!("{:?}", response);
607−
608606 let items = match response {
609607 Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
610608 Some(lsp::GotoDefinitionResponse::Array(location_vec)) => location_vec,
helix-term/src/commands.rs+8
@@ -861,6 +861,14 @@ pub fn goto_definition(cx: &mut Context) {
861861 let res =
862862 smol::block_on(language_server.goto_definition(doc.identifier(), pos)).unwrap_or_default();
863863
864+ if res.len() == 1 {
865+ let definition_pos = res.get(0).unwrap().range.start;
866+ let new_pos = helix_lsp::util::lsp_pos_to_pos(doc.text().slice(..), definition_pos);
867+ doc.set_selection(Selection::point(new_pos));
868+ } else {
869+ // show menu picker i guess
870+ }
871+
864872 doc.mode = Mode::Normal;
865873}
866874