lean4-htt/src/Lean
Marc Huisinga 95aee36fab
feat: inlay hints for auto-implicits (#6768)
This PR adds preliminary support for inlay hints, as well as support for
inlay hints that denote the auto-implicits of a function. Hovering over
an auto-implicit displays its type and double-clicking the auto-implicit
inserts it into the text document.

![Inlay hints for
auto-implicits](https://github.com/user-attachments/assets/fb204c42-5997-4f10-9617-c65f1042d732)

This PR is an extension of #3910.

### Known issues

- In VS Code, when inserting an inlay hint, the inlay hint may linger
for a couple of seconds before it disappears. This is a defect of the VS
Code implementation of inlay hints and cannot adequately be resolved by
us.
- When making a change to the document, it may take a couple of seconds
until the inlay hints respond to the change. This is deliberate and
intended to reduce the amount of inlay hint flickering while typing. VS
Code has a mechanism of its own for this, but in my experience it is
still far too sensitive without additional latency.
- Inserting an auto-implicit inlay hint that depends on an auto-implicit
meta-variable causes a "failed to infer binder type" error. We can't
display these meta-variables in the inlay hint because they don't have a
user-displayable name, so it is not clear how to resolve this problem.
- Inlay hints are currently always resolved eagerly, i.e. we do not
support the `textDocument/inlayHint/resolve` request yet. Implementing
support for this request is future work.

### Other changes
- Axioms did not support auto-implicits due to an oversight in the
implementation. This PR ensures they do.
- In order to reduce the amount of inlay hint flickering when making a
change to the document, the language server serves old inlay hints for
parts of the file that have not been processed yet. This requires LSP
request handler state (that sometimes must be invalidated on
`textDocument/didChange`), so this PR introduces the notion of a
stateful LSP request handler.
- The partial response mechanism that we use for semantic tokens, where
we simulate incremental LSP responses by periodically emitting refresh
requests to the client, is generalized to accommodate both inlay hints
and semantic tokens. Additionally, it is made more robust to ensure that
we never emit refresh requests while a corresponding request is in
flight, which causes VS Code to discard the respond of the request, as
well as to ensure that we keep prompting VS Code to send another request
if it spuriously decides not to respond to one of our refresh requests.
- The synthetic identifier of an `example` had the full declaration as
its (non-canonical synthetic) range. Since we need a reasonable position
for the identifier to insert an inlay hint for the auto-implicits of an
`example`, we change the (canonical synthetic) range of the synthetic
identifier to that of the `example` keyword.
- The semantic highlighting request handling is moved to a separate
file.

### Breaking changes
- The semantic highlighting request handler is not a pure request
handler anymore, but a stateful one. Notably, this means that clients
that extend the semantic highlighting of the Lean language server with
the `chainLspRequestHandler` function must now use the
`chainStatefulLspRequestHandler` function instead.
2025-02-04 17:36:49 +00:00
..
Compiler fix: don't strip macro scopes in names of specialized LCNF decls (#6930) 2025-02-04 03:43:18 +00:00
Data feat: inlay hints for auto-implicits (#6768) 2025-02-04 17:36:49 +00:00
DocString fix: Lake: brittle dependency on env ext name 2024-10-07 13:26:07 +02:00
Elab feat: inlay hints for auto-implicits (#6768) 2025-02-04 17:36:49 +00:00
Language chore: disable Elab.async on the cmdline for now (#6722) 2025-01-22 18:25:47 +00:00
Linter chore: import cleanup in Init (#6522) 2025-01-04 04:13:13 +00:00
Meta feat: improve simp trace formatting (#6951) 2025-02-04 15:47:01 +00:00
Parser feat: allow anonymous equality proofs in match expressions (#6853) 2025-02-04 16:09:21 +00:00
ParserCompiler
PrettyPrinter feat: make all app unexpanders respond to pp.tagAppFns (#6730) 2025-02-02 23:29:12 +00:00
Server feat: inlay hints for auto-implicits (#6768) 2025-02-04 17:36:49 +00:00
Util feat: asynchronous code generation (#6770) 2025-02-03 17:17:18 +00:00
Widget feat: generalize infoview.maxTraceChildren to the cmdline (#6716) 2025-01-21 02:06:24 +00:00
AddDecl.lean feat: asynchronous code generation (#6770) 2025-02-03 17:17:18 +00:00
Attributes.lean refactor: dead code AttributeExtensionOLeanEntry.decl (#5496) 2024-10-01 13:34:12 +00:00
AuxRecursor.lean
BuiltinDocAttr.lean
Class.lean chore: move MessageData.ofConstName earlier (#5877) 2024-10-29 21:23:51 +00:00
Compiler.lean
CoreM.lean feat: asynchronous code generation (#6770) 2025-02-03 17:17:18 +00:00
Data.lean feat: add date and time functionality (#4904) 2024-11-14 14:04:19 +00:00
Declaration.lean feat: add support for constructors and axioms to the grind E-matching module (#6839) 2025-01-29 05:22:05 +00:00
DeclarationRange.lean feat: labeled and unique sorries (#5757) 2024-12-11 23:53:02 +00:00
DocString.lean feat: recommended_spelling command (#6869) 2025-02-03 11:15:52 +00:00
Elab.lean feat: recommended_spelling command (#6869) 2025-02-03 11:15:52 +00:00
Environment.lean feat: asynchronous code generation (#6770) 2025-02-03 17:17:18 +00:00
Exception.lean feat: split Lean.Kernel.Environment from Lean.Environment (#5145) 2025-01-18 18:42:57 +00:00
Expr.lean chore: fix typo in docstring of mkMVar (#6687) 2025-01-18 12:28:33 +00:00
HeadIndex.lean
Hygiene.lean
ImportingFlag.lean
InternalExceptionId.lean feat: change Array.get to take a Nat and a proof (#6032) 2024-11-12 03:30:46 +00:00
KeyedDeclsAttribute.lean
LabelAttribute.lean chore: update copyrights (#5449) 2024-09-24 05:27:53 +00:00
Level.lean fix: add a missing case to Level.geq (#2689) 2024-11-19 21:27:00 +00:00
Linter.lean
LoadDynlib.lean feat: Lean.loadPlugin (#6130) 2024-11-27 09:56:31 +00:00
LocalContext.lean doc: split the docstring of LocalContext (#6340) 2024-12-15 21:35:25 +00:00
Log.lean
Message.lean feat: generalize infoview.maxTraceChildren to the cmdline (#6716) 2025-01-21 02:06:24 +00:00
Meta.lean feat: labeled and unique sorries (#5757) 2024-12-11 23:53:02 +00:00
MetavarContext.lean feat: Nat.(fold|foldRev|any|all)M? take a function which sees the upper bound (#6139) 2024-11-22 03:05:51 +00:00
Modifiers.lean feat: Environment.addConstAsync (#6691) 2025-01-19 02:00:16 +00:00
MonadEnv.lean fix: bring elaborator in line with kernel for primitive projections (#5822) 2024-10-31 03:16:52 +00:00
Parser.lean
ParserCompiler.lean feat: rename List.enum(From) to List.zipIdx, and Array/Vector.zipWithIndex to zipIdx (#6800) 2025-01-28 23:34:30 +00:00
PrettyPrinter.lean feat: do not propagate pretty printer errors through messages (#3696) 2024-12-11 04:10:09 +00:00
PrivateName.lean feat: Environment.addConstAsync (#6691) 2025-01-19 02:00:16 +00:00
ProjFns.lean
ReducibilityAttrs.lean
Replay.lean refactor: move registration of namespaces on kernel add into elaborator (#6214) 2025-01-18 23:01:29 +00:00
ReservedNameAction.lean
ResolveName.lean fix: when pretty printing constant names, do not use aliases from "non-API exports" (#5689) 2024-12-10 17:50:50 +00:00
Runtime.lean
ScopedEnvExtension.lean
Server.lean
Structure.lean feat: Array.insertIdx/eraseIdx take a tactic-provided proof (#6133) 2024-11-20 09:52:38 +00:00
SubExpr.lean chore: cleanup imports (#5825) 2024-10-23 23:51:13 +00:00
Syntax.lean feat: inlay hints for auto-implicits (#6768) 2025-02-04 17:36:49 +00:00
ToExpr.lean feat: upstream ToExpr deriving handler from Mathlib (#6473) 2024-12-31 15:11:53 +00:00
ToLevel.lean feat: upstream ToLevel from mathlib (#6285) 2024-12-05 05:50:32 +00:00
Util.lean feat: add Expr.fvarsSubset (#6430) 2024-12-20 22:29:47 +00:00
Widget.lean