feat(lsp): provide hover info for import map resolutions#34854
Merged
Conversation
When hovering over an import specifier that was remapped through an import map, the resolved-dependency hover now appends an "Import Map" line showing the matched key and value, e.g.: **Import Map**: `@std/path` → `jsr:@std/path@^1` _(deno.json)_ The matched entry is found by reverse-lookup on the resolved specifier (mirroring `import_map::ImportMap::lookup`), additionally requiring the entry to reconstruct the exact specifier that was written so a relative import that merely lands in a mapped directory is not mislabelled. Co-Authored-By: Divy Srivastava <[email protected]>
The previous run's 'lint debug' jobs failed because the denoland/setup-deno 'Install Deno' step crashed on the Windows runner (exit 0xC0000409, STATUS_STACK_BUFFER_OVERRUN) before lint.js/clippy ran; the linux/macos legs were cancelled by matrix fail-fast. No code change. Co-Authored-By: Divy Srivastava <[email protected]>
The new "**Import Map**" hover line is appended for any import-map-resolved dependency, so the existing exact-match hover assertions in lsp_hover_typescript_types_via_import_map, lsp_deno_json_workspace_import_map and lsp_deno_json_scopes_import_map now include it. Co-Authored-By: Divy Srivastava <[email protected]>
In a workspace, member import maps are merged into the workspace-root import map with values rebased relative to the root deno.json, so the project2 entry displays as `./project2/foo2.ts` rather than `./foo2.ts`. Co-Authored-By: Divy Srivastava <[email protected]>
littledivy
force-pushed
the
orch/divybot-467
branch
from
June 5, 2026 13:18
99f8a21 to
c5f56fd
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.
When hovering over a specifier that resolves via an import map, the language server now surfaces the import map resolution in the hover tooltip.
Previously, hovering over an import specifier only showed the resolved Code/Types target. Now, when that specifier was remapped through an import map, an additional line is appended:
Implementation
cli/lsp/resolver.rs: addsImportMapHoverandLspScopedResolver::import_map_hover(specifier, code, referrer). The responsible entry is found by reverse-lookup on the resolved URL (mirroringimport_map::ImportMap::lookup) — an entry matches when its address equals (literal mapping) or is a prefix of (/-suffixed mapping) the resolved specifier. It additionally requires the entry to reconstruct the exact specifier that was written, so a relative import that merely lands inside a mapped directory is not mislabelled as an import map resolution. The displayed key/value are the raw text from the import map file.cli/lsp/language_server.rs:Inner::hovernow passes the written specifier text and resolved code URL toimport_map_hoverand appends the rendered line to the resolved-dependency hover.Test
tests/integration/lsp_tests.rs::lsp_hover_dependency_import_mapcovers both a literal mapping (foo→./lib/foo.ts) and a prefix mapping (bar/→./lib/bar/).Closes #13622
Closes denoland/divybot#467