Skip to content

feat: improve semantic highlighting (close #2305) - #13726

Closed
RIvance wants to merge 7 commits into
leanprover:masterfrom
RIvance:patch-highlighting
Closed

RIvance wants to merge 7 commits into
leanprover:masterfrom
RIvance:patch-highlighting

Conversation

@RIvance

@RIvance RIvance commented May 13, 2026 •

Copy link
Copy Markdown

This PR improves semantic highlighting (addresses #2305) by reusing information already present in the InfoTree and elaboration context.

This PR DOES NOT:

  • change any public API
  • OR add/modify constructors to existing inductive definitions
  • OR change the InfoTree structure.

It also DOES NOT require any change in lean4-vscode extension because the server still emits standard semantic token types from the existing SemanticTokenType.

No new token kinds are introduced, so existing VS Code themes should continue to work.

The mapping is:

Lean entity Token type
Universe expressions / universe-valued identifiers, e.g. Type, Sort class
Type parameters, e.g. (A : Type) and uses of A typeParameter
Typeclass declarations interface
Structures / records struct
Propositions and proposition families, e.g. P : Prop, P : A → Prop enum
Type constructors and type families, e.g. T : Type, F : A → Type type
Ordinary inductive datatypes type
Inductive propositions / prop families enum
Constructors enumMember
Projection fields and projection functions property
Term-level definitions, theorems, axioms, opaque declarations, recursors that are not type/proposition families function
Term-level local binders, e.g. (x : Nat) parameter
Term-level local uses / proof hypotheses not classified above variable
Keywords, strings, numbers, Verso doc tokens, sorry-like tokens keep existing behavior

The PR also handles declaration names and self-references while the declaration is still being elaborated, including recursive function calls and inductive self-references in constructor types.

Closes #2305

AI Usage: I acknowledge the use of Codex GPT-5.5 for assistance in coding, code review, and test case generation.

LHS: With Semantic Highlighting; RHS: Without Semantic Highlighting

Screenshot From 2026-05-13 22-21-26 Screenshot From 2026-05-13 22-21-50 Screenshot From 2026-05-13 22-54-54

@RIvance
RIvance force-pushed the patch-highlighting branch 2 times, most recently from ad0d817 to a7710f4 Compare May 13, 2026 15:01
@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label May 13, 2026
@mathlib-lean-pr-testing

mathlib-lean-pr-testing Bot commented May 13, 2026 •

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase bba3868b3b1dfd7741d33b119f73b5d342b9f1d5 --onto ed0d50fcf0efa8c9a32e1ccb3603ce43edce6926. You can force Mathlib CI using the force-mathlib-ci label. (2026-05-13 16:31:23)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 2acdaafcfe34015fba2490e68600d5c4585f5a47 --onto 803553a556fd82fa1060efb0c43eda542130cb16. You can force Mathlib CI using the force-mathlib-ci label. (2026-05-15 11:08:32)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 1b8f1f140c56d214b2171abe8675fb8582670fef --onto 803553a556fd82fa1060efb0c43eda542130cb16. You can force Mathlib CI using the force-mathlib-ci label. (2026-05-16 08:48:55)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 50e882b0dff5001d7dc1320f91c3fbcb610aad31 --onto c47a0c7cf035381a2bcdd4cdf2442782eb4a5214. You can force Mathlib CI using the force-mathlib-ci label. (2026-06-02 09:20:54)

@leanprover-bot

leanprover-bot commented May 13, 2026 •

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase bba3868b3b1dfd7741d33b119f73b5d342b9f1d5 --onto ed0d50fcf0efa8c9a32e1ccb3603ce43edce6926. You can force reference manual CI using the force-manual-ci label. (2026-05-13 16:31:26)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 2acdaafcfe34015fba2490e68600d5c4585f5a47 --onto 803553a556fd82fa1060efb0c43eda542130cb16. You can force reference manual CI using the force-manual-ci label. (2026-05-15 11:08:34)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 1b8f1f140c56d214b2171abe8675fb8582670fef --onto 803553a556fd82fa1060efb0c43eda542130cb16. You can force reference manual CI using the force-manual-ci label. (2026-05-16 08:48:56)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 50e882b0dff5001d7dc1320f91c3fbcb610aad31 --onto 803553a556fd82fa1060efb0c43eda542130cb16. You can force reference manual CI using the force-manual-ci label. (2026-06-02 09:20:55)

@RIvance
RIvance marked this pull request as ready for review May 13, 2026 17:52
@RIvance
RIvance requested a review from mhuisi as a code owner May 13, 2026 17:52
@Kha Kha added the missing RFC Non-trivial PR requiring accepted RFC first label May 27, 2026
@RIvance

RIvance commented Nov 1, 2026

Copy link
Copy Markdown
Author

closing this in favor of #16151 with RFC #16150

@RIvance RIvance closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing RFC Non-trivial PR requiring accepted RFC first toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: Improved Semantic Highlighting

3 participants