@@ -475,6 +475,21 @@ fn goto_impl(
478+fn to_locations(definitions: Option<lsp::GotoDefinitionResponse>) -> Vec<lsp::Location> {
480+ Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
481+ Some(lsp::GotoDefinitionResponse::Array(locations)) => locations,
482+ Some(lsp::GotoDefinitionResponse::Link(locations)) => locations
484+ .map(|location_link| lsp::Location {
485+ uri: location_link.target_uri,
486+ range: location_link.target_range,
478pub fn goto_definition(cx: &mut Context) {
493pub fn goto_definition(cx: &mut Context) {
479 let (view, doc) = current!(cx.editor);
494 let (view, doc) = current!(cx.editor);
480 let language_server = language_server!(doc);
495 let language_server = language_server!(doc);
@@ -492,22 +507,8 @@ pub fn goto_definition(cx: &mut Context) {
493 cx.callback(
508 cx.callback(
495− move |editor: &mut Editor,
496− compositor: &mut Compositor,
497− response: Option<lsp::GotoDefinitionResponse>| {
510+ move |editor, compositor, response: Option<lsp::GotoDefinitionResponse>| {
498− let items = match response {
511+ let items = to_locations(response);
499− Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
500− Some(lsp::GotoDefinitionResponse::Array(locations)) => locations,
501− Some(lsp::GotoDefinitionResponse::Link(locations)) => locations
503− .map(|location_link| lsp::Location {
504− uri: location_link.target_uri,
505− range: location_link.target_range,
511 goto_impl(editor, compositor, items, offset_encoding);
512 goto_impl(editor, compositor, items, offset_encoding);
@@ -530,22 +531,8 @@ pub fn goto_type_definition(cx: &mut Context) {
531 cx.callback(
532 cx.callback(
533− move |editor: &mut Editor,
534− compositor: &mut Compositor,
535− response: Option<lsp::GotoDefinitionResponse>| {
534+ move |editor, compositor, response: Option<lsp::GotoDefinitionResponse>| {
536− let items = match response {
535+ let items = to_locations(response);
537− Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
538− Some(lsp::GotoDefinitionResponse::Array(locations)) => locations,
539− Some(lsp::GotoDefinitionResponse::Link(locations)) => locations
541− .map(|location_link| lsp::Location {
542− uri: location_link.target_uri,
543− range: location_link.target_range,
549 goto_impl(editor, compositor, items, offset_encoding);
536 goto_impl(editor, compositor, items, offset_encoding);
@@ -568,22 +555,8 @@ pub fn goto_implementation(cx: &mut Context) {
569 cx.callback(
556 cx.callback(
571− move |editor: &mut Editor,
572− compositor: &mut Compositor,
573− response: Option<lsp::GotoDefinitionResponse>| {
558+ move |editor, compositor, response: Option<lsp::GotoDefinitionResponse>| {
574− let items = match response {
559+ let items = to_locations(response);
575− Some(lsp::GotoDefinitionResponse::Scalar(location)) => vec![location],
576− Some(lsp::GotoDefinitionResponse::Array(locations)) => locations,
577− Some(lsp::GotoDefinitionResponse::Link(locations)) => locations
579− .map(|location_link| lsp::Location {
580− uri: location_link.target_uri,
581− range: location_link.target_range,
587 goto_impl(editor, compositor, items, offset_encoding);
560 goto_impl(editor, compositor, items, offset_encoding);
@@ -606,15 +579,9 @@ pub fn goto_reference(cx: &mut Context) {
607 cx.callback(
580 cx.callback(
609− move |editor: &mut Editor,
610− compositor: &mut Compositor,
611− items: Option<Vec<lsp::Location>>| {
582+ move |editor, compositor, response: Option<Vec<lsp::Location>>| {
615− items.unwrap_or_default(),
583+ let items = response.unwrap_or_default();
616− offset_encoding,
584+ goto_impl(editor, compositor, items, offset_encoding);
@@ -635,9 +602,7 @@ pub fn signature_help(cx: &mut Context) {
636 cx.callback(
603 cx.callback(
638− move |_editor: &mut Editor,
639− _compositor: &mut Compositor,
640− response: Option<lsp::SignatureHelp>| {
605+ move |_editor, _compositor, response: Option<lsp::SignatureHelp>| {
641 if let Some(signature_help) = response {
606 if let Some(signature_help) = response {
642 log::info!("{:?}", signature_help);
607 log::info!("{:?}", signature_help);
643 // signatures
608 // signatures