aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorJan Hrastnik2021-02-21 22:43:28 +0000
committerBlaž Hrastnik2021-03-16 14:03:10 +0000
commit8a68a043400342a02496c4ff622dd86e6f40a89c (patch)
tree665194f964b704cc58894d776642fb8fb074b8cd /helix-term
parentd3ddc8dea6844f836199196c44b08e63fdf837d0 (diff)
gotodefiniton now runs but doesnt return anything
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 98e79b44..8b7e3600 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -846,7 +846,27 @@ pub fn exit_select_mode(cx: &mut Context) {
cx.doc().mode = Mode::Normal;
}
-pub fn goto_definition(cx: &mut Context) {}
+pub fn goto_definition(cx: &mut Context) {
+ let language_server = cx
+ .editor
+ .language_servers
+ .get("source.rust", &cx.executor)
+ .unwrap();
+ use log::info;
+
+ let doc = cx.doc();
+
+ // TODO: blocking here is not ideal
+ let pos = helix_lsp::util::pos_to_lsp_pos(doc.text().slice(..), doc.selection().cursor());
+
+ // TODO: handle fails
+ let res = smol::block_on(language_server.goto_definition(cx.doc().identifier(), pos))
+ .unwrap_or_default();
+
+ println!("{:?}", res);
+
+ cx.doc().mode = Mode::Normal;
+}
// NOTE: Transactions in this module get appended to history when we switch back to normal mode.
pub mod insert {