From 4eca4b3079bf53de874959270d0b3471d320debc Mon Sep 17 00:00:00 2001 From: Ole Krüger Date: Tue, 31 Jan 2023 11:38:53 +0100 Subject: Support goto-declaration LSP command (#5646) --- helix-term/src/commands/lsp.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'helix-term/src/commands/lsp.rs') diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index 578eb608..d12aa436 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -914,6 +914,31 @@ fn to_locations(definitions: Option) -> Vec future, + None => { + cx.editor + .set_error("Language server does not support goto-declaration"); + return; + } + }; + + cx.callback( + future, + move |editor, compositor, response: Option| { + let items = to_locations(response); + goto_impl(editor, compositor, items, offset_encoding); + }, + ); +} + pub fn goto_definition(cx: &mut Context) { let (view, doc) = current!(cx.editor); let language_server = language_server!(cx.editor, doc); -- cgit v1.2.3-70-g09d2