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

@ -582,4 +582,43 @@ impl Client {
Ok(response.unwrap_or_default())
}
pub async fn goto_definition(
&self,
text_document: lsp::TextDocumentIdentifier,
position: lsp::Position,
) -> anyhow::Result<Vec<lsp::Location>> {
let params = lsp::GotoDefinitionParams {
text_document_position_params: lsp::TextDocumentPositionParams {
text_document,
position,
},
work_done_progress_params: lsp::WorkDoneProgressParams {
work_done_token: None,
},
partial_result_params: lsp::PartialResultParams {
partial_result_token: None,
},
};
let response = self.request::<lsp::request::GotoDefinition>(params).await?;
let items = match response {
Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
Some(lsp::GotoDefinitionResponse::Array(location_vec)) => location_vec,
Some(lsp::GotoDefinitionResponse::Link(location_link_vec)) => {
let mut location_vec: Vec<lsp::Location> = Vec::new();
location_link_vec.into_iter().for_each(|location_link| {
let link = lsp::Location {
uri: location_link.target_uri,
range: location_link.target_range,
};
location_vec.append(&mut link);
});
location_vec
}
};
Ok(items)
}
}

@ -846,6 +846,8 @@ pub fn exit_select_mode(cx: &mut Context) {
cx.doc().mode = Mode::Normal;
}
pub fn goto_definition(cx: &mut Context) {}
// NOTE: Transactions in this module get appended to history when we switch back to normal mode.
pub mod insert {
use super::*;

@ -311,8 +311,12 @@ pub fn default() -> Keymaps {
code: KeyCode::Esc,
modifiers: Modifiers::NONE
} => commands::normal_mode as Command,
key!('g') => commands::move_file_start as Command,
key!('e') => commands::move_file_end as Command,
key!('g') => commands::move_file_start,
key!('e') => commands::move_file_end,
key!('d') => commands::goto_definition,
key!('t') => commands::goto_type_definition,
key!('r') => commands::goto_reference,
key!('i') => commands::goto_implementation,
),
)
}

@ -0,0 +1 @@
awdwadwadwa njvkrnvjre eahdwau kjvreng
Loading…
Cancel
Save