leanprover / leanprover/lean4

Go-to-definition for types in hover

Open
#1,117 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement nice to have P-medium server
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

@Kha suggested exploring how go to definition could look like for a type shown in a hover. It seems the front end part of this feature would work quite well, with a few drawbacks.

  1. Markdown code blocks ( ```lean) do not support links, so we would need to switch to language independent HTML code blocks (<code>) for the type in the hover (not for the documentation with possible lean code examples).
  2. This would require enabling HTML in hovers in the client (with a limited set of allowed tags for security reasons), which is currently only support per MarkdownString, i.e. needs to be set for each incoming hover text. This is supposed to change with LSP 3.17 (see this issue).
  3. Although this works in VSCode and other Markdown renderers, I'm not sure if links (of the form []()) are always rendered as such inside HTML code blocks, which might be relevant for other editors or if a renderer is changed.
  4. HTML code blocks do not fill the hover completely and have a slightly darker background, which looks a bit weird.

The benefit, of course, is the possibility of jumping to the definition of a type appearing in the type of an expression in the code, which I find quite useful. What do you all think of it?

grafik

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name repository files, tests, or entry points. Start with the listed hover-rendering constraints and the linked LSP 3.17 discussion; done would require an agreed implementation path for type links rather than leaving the open design questions unresolved.

Written by the indexing model from the issue text.

Assessment

Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.