@@ -914,6 +914,31 @@ fn to_locations(definitions: Option<lsp::GotoDefinitionResponse>) -> Vec<lsp::Lo
914914 }
915915}
916916
917+pub fn goto_declaration(cx: &mut Context) {
918+ let (view, doc) = current!(cx.editor);
919+ let language_server = language_server!(cx.editor, doc);
920+ let offset_encoding = language_server.offset_encoding();
921+
922+ let pos = doc.position(view.id, offset_encoding);
923+
924+ let future = match language_server.goto_declaration(doc.identifier(), pos, None) {
925+ Some(future) => future,
926+ None => {
927+ cx.editor
928+ .set_error("Language server does not support goto-declaration");
929+ return;
930+ }
931+ };
932+
933+ cx.callback(
934+ future,
935+ move |editor, compositor, response: Option<lsp::GotoDefinitionResponse>| {
936+ let items = to_locations(response);
937+ goto_impl(editor, compositor, items, offset_encoding);
938+ },
939+ );
940+}
941+
917942pub fn goto_definition(cx: &mut Context) {
918943 let (view, doc) = current!(cx.editor);
919944 let language_server = language_server!(cx.editor, doc);