diff --git a/book/src/configuration.md b/book/src/configuration.md index 1fdbf00520fa..253a07269d18 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -128,6 +128,7 @@ The following statusline elements can be configured: | `display-inlay-hints` | Display inlay hints[^2] | `false` | | `display-signature-help-docs` | Display docs under signature help popup | `true` | | `snippets` | Enables snippet completions. Requires a server restart (`:lsp-restart`) to take effect after `:config-reload`/`:set`. | `true` | +| `goto-reference-include-declaration` | Include declaration in the goto references popup. | `true` | [^1]: By default, a progress spinner is shown in the statusline beside the file path. [^2]: You may also have to activate them in the LSP config for them to appear, not just in Helix. diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 93e822c44420..89b714e21263 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -1167,6 +1167,7 @@ impl Client { &self, text_document: lsp::TextDocumentIdentifier, position: lsp::Position, + include_declaration: bool, work_done_token: Option, ) -> Option>> { let capabilities = self.capabilities.get().unwrap(); @@ -1183,7 +1184,7 @@ impl Client { position, }, context: lsp::ReferenceContext { - include_declaration: true, + include_declaration, }, work_done_progress_params: lsp::WorkDoneProgressParams { work_done_token }, partial_result_params: lsp::PartialResultParams { diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index b5d1d337ede3..0ad6fb7eb4b4 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -1078,13 +1078,19 @@ pub fn goto_implementation(cx: &mut Context) { } pub fn goto_reference(cx: &mut Context) { + let config = cx.editor.config(); let (view, doc) = current!(cx.editor); let language_server = language_server!(cx.editor, doc); let offset_encoding = language_server.offset_encoding(); let pos = doc.position(view.id, offset_encoding); - let future = match language_server.goto_reference(doc.identifier(), pos, None) { + let future = match language_server.goto_reference( + doc.identifier(), + pos, + config.lsp.goto_reference_include_declaration, + None, + ) { Some(future) => future, None => { cx.editor diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 52f86f2da467..fd0abe91dbcb 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -354,6 +354,8 @@ pub struct LspConfig { pub display_inlay_hints: bool, /// Whether to enable snippet support pub snippets: bool, + /// Whether to include declaration in the goto reference query + pub goto_reference_include_declaration: bool, } impl Default for LspConfig { @@ -365,6 +367,7 @@ impl Default for LspConfig { display_signature_help_docs: true, display_inlay_hints: false, snippets: true, + goto_reference_include_declaration: true, } } }