gotodefiniton now runs but doesnt return anything

pull/8/head
Jan Hrastnik 4 years ago committed by Blaž Hrastnik
parent d3ddc8dea6
commit 8a68a04340

@ -603,6 +603,8 @@ impl Client {
let response = self.request::<lsp::request::GotoDefinition>(params).await?; let response = self.request::<lsp::request::GotoDefinition>(params).await?;
println!("{:?}", response);
let items = match response { let items = match response {
Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location], Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
Some(lsp::GotoDefinitionResponse::Array(location_vec)) => location_vec, Some(lsp::GotoDefinitionResponse::Array(location_vec)) => location_vec,
@ -613,10 +615,11 @@ impl Client {
uri: location_link.target_uri, uri: location_link.target_uri,
range: location_link.target_range, range: location_link.target_range,
}; };
location_vec.append(&mut link); location_vec.push(link)
}); });
location_vec location_vec
} }
None => Vec::new(),
}; };
Ok(items) Ok(items)

@ -846,7 +846,27 @@ pub fn exit_select_mode(cx: &mut Context) {
cx.doc().mode = Mode::Normal; 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. // NOTE: Transactions in this module get appended to history when we switch back to normal mode.
pub mod insert { pub mod insert {

Loading…
Cancel
Save