Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions book/src/guides/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ The following [captures][tree-sitter-captures] are recognized:
| `definition.module` |
| `definition.struct` |
| `definition.type` |
| `reference.class` |
| `reference.constant` |
| `reference.function` |
| `reference.interface` |
| `reference.macro` |
| `reference.module` |
| `reference.struct` |
| `reference.type` |

[Example query files][example-queries] can be found in the Helix GitHub
repository.
Expand Down
103 changes: 82 additions & 21 deletions helix-term/src/commands/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use helix_lsp::{
use tokio_stream::StreamExt;
use tui::{text::Span, widgets::Row};

use super::{align_view, push_jump, Align, Context, Editor};
use super::{
align_view, push_jump, search_selection_impl, syntax_workspace_symbol_picker, syntax_workspace_symbol_reference_picker, Align, Context, Editor
};

use helix_core::{
diagnostic::DiagnosticProvider, syntax::config::LanguageServerFeature,
Expand Down Expand Up @@ -951,38 +953,97 @@ where
}

pub fn goto_declaration(cx: &mut Context) {
goto_single_impl(
cx,
LanguageServerFeature::GotoDeclaration,
|ls, pos, doc_id| ls.goto_declaration(doc_id, pos, None),
);
let doc = doc!(cx.editor);

if doc
.language_servers_with_feature(LanguageServerFeature::GotoDeclaration)
.next()
.is_some()
{
goto_single_impl(
cx,
LanguageServerFeature::GotoDeclaration,
|ls, pos, doc_id| ls.goto_declaration(doc_id, pos, None),
);
} else {
search_selection_impl(cx, false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with_line from picker doesn't work i.e UI doesn't get updated automatically so using this as workaround, same for other calls below

syntax_workspace_symbol_picker(cx);
}
}

pub fn goto_definition(cx: &mut Context) {
goto_single_impl(
cx,
LanguageServerFeature::GotoDefinition,
|ls, pos, doc_id| ls.goto_definition(doc_id, pos, None),
);
let doc = doc!(cx.editor);

if doc
.language_servers_with_feature(LanguageServerFeature::GotoDefinition)
.next()
.is_some()
{
goto_single_impl(
cx,
LanguageServerFeature::GotoDefinition,
|ls, pos, doc_id| ls.goto_definition(doc_id, pos, None),
);
} else {
search_selection_impl(cx, false);
syntax_workspace_symbol_picker(cx);
}
}

pub fn goto_type_definition(cx: &mut Context) {
goto_single_impl(
cx,
LanguageServerFeature::GotoTypeDefinition,
|ls, pos, doc_id| ls.goto_type_definition(doc_id, pos, None),
);
let doc = doc!(cx.editor);

if doc
.language_servers_with_feature(LanguageServerFeature::GotoTypeDefinition)
.next()
.is_some()
{
goto_single_impl(
cx,
LanguageServerFeature::GotoTypeDefinition,
|ls, pos, doc_id| ls.goto_type_definition(doc_id, pos, None),
);
} else {
search_selection_impl(cx, false);
syntax_workspace_symbol_picker(cx);
}
}

pub fn goto_implementation(cx: &mut Context) {
goto_single_impl(
cx,
LanguageServerFeature::GotoImplementation,
|ls, pos, doc_id| ls.goto_implementation(doc_id, pos, None),
);
let doc = doc!(cx.editor);

if doc
.language_servers_with_feature(LanguageServerFeature::GotoImplementation)
.next()
.is_some()
{
goto_single_impl(
cx,
LanguageServerFeature::GotoImplementation,
|ls, pos, doc_id| ls.goto_implementation(doc_id, pos, None),
);
} else {
search_selection_impl(cx, false);
syntax_workspace_symbol_picker(cx);
}
}

pub fn goto_reference(cx: &mut Context) {
let doc = doc!(cx.editor);

if doc
.language_servers_with_feature(LanguageServerFeature::GotoReference)
.next()
.is_some() {
goto_reference_picker(cx)

} else {
search_selection_impl(cx, false);
syntax_workspace_symbol_reference_picker(cx);
}
}

pub fn goto_reference_picker(cx: &mut Context) {
let config = cx.editor.config();
let (view, doc) = current_ref!(cx.editor);

Expand Down
Loading
Loading