input: add Lsp::show_document hook following LSP window/showDocument#2569
Merged
Conversation
Hosts can intercept LSP locations before the built-in handling (http(s) opens in browser, otherwise same-document jump) -- e.g. to open a virtual navi-doc:// URI in an in-app docs window. Return true to mark the location handled.
huacnlee
reviewed
Jul 14, 2026
Rename on_open_location to on_show_document and pass lsp_types::ShowDocumentParams (uri, external, take_focus, selection) instead of a raw LocationLink, following the window/showDocument request from the LSP spec. The default in-document jump now selects target_selection_range per the spec, instead of target_range. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ylinwind
force-pushed
the
input-open-location-hook-0.5
branch
from
July 15, 2026 02:23
3c1bd60 to
e007d25
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional
Lsp::on_show_documenthost hook onInputState, called at the start ofgo_to_definitionbefore the built-in handling. The hook is modeled after the LSPwindow/showDocumentrequest:The component builds
ShowDocumentParamsfrom the resolvedLocationLink(uri,externalfor http(s) targets,take_focus,selectionfromtargetSelectionRange).true: the host has shown the document; the component does nothing further.false(or hook unset): falls through to the existing behavior —externalURIs open in the browser, anything else jumps within the current document.The default in-document jump now selects
targetSelectionRange(the range the spec says should be selected and revealed when following a link) instead oftargetRange.Why
The built-in Go to Definition can only jump within the current document or open a browser URL. Language providers that resolve symbols into virtual/external documents (e.g. NaviScript stdlib symbols resolving to
navi-doc://module/name) need a way to route Cmd+Click to an in-app docs window. Without a hook, non-http cross-file locations would be misinterpreted as same-document ranges and jump to a wrong position.window/showDocumentis the spec's standard "client, show this document" abstraction, so the hook reuses its params shape rather than inventing a new one.Notes
d1c48828(the rev currently pinned by longbridge-gpui's Cargo.lock) so it can be consumed immediately; happy to rebase ontomainif preferred.go_to_definition(crate-private) gains a&mut Windowparameter; both internal call sites already had a window in scope.🤖 Generated with Claude Code