Commit graph

39 commits

Author SHA1 Message Date
Joachim Breitner
1a12f63f74
refactor: move Synax.hasIdent, shake dependencies (#4766)
I noticed that a change to `Lean.PrettyPrinter.Delaborator.Builtins`
rebuilt more modules than I expected, so I moved a definition and
reduced some dependcies.

More reduction would be possible to move const-delaboration out of the
big `Lean.PrettyPrinter`, and import from `Lean.PrettyPrinter`
selectively.
2024-07-16 21:19:26 +00:00
Kyle Miller
3f2cf8bf27
fix: set default value of pp.instantiateMVars to true and make the option be effective (#4558)
Before, `pp.instantiateMVars` generally had no effect because most call
sites for the pretty printer instantiated metavariables first, but now
this functionality is entrusted upon the `pp.instantiateMVars` option.

This also has an effect in hovers, where metavariables can be unfolded
one assignment at a time. However, the goal state still sees all
metavariables instantiated due to the fact that the algorithm relies on
expression equality post-instantiation (see
`Lean.Widget.goalToInteractive`).

Closes #4406
2024-07-02 22:59:44 +00:00
Kyle Miller
9cb114eb83
feat: add pp.mvars and pp.mvars.withType (#3798)
* Setting `pp.mvars` to false causes metavariables to pretty print as
`?_`.
* Setting `pp.mvars.withType` to true causes metavariables to pretty
print with type ascriptions.

Motivation: when making tests, it is inconvenient using `#guard_msgs`
when there are metavariables, since the unique numbering is subject to
change.

This feature does not use `⋯` omissions since a metavariable is already
in a sense an omitted term. If repeated metavariables do not appear in
an expression, there is a chance that a term pretty printed with
`pp.mvars` set to false can still elaborate to the correct term, unlike
for other omissions.

(In the future we could consider an option that pretty prints uniquely
numbered metavariables as `?m✝`, `?m✝¹`, `?m✝²`, etc. to be able to tell
them apart, at least in the same pretty printed expression. It would
take care to make sure that these names are stable across different
hovers.)

Closes #3781
2024-03-29 18:03:05 +00:00
Henrik Böving
23e49eb519 perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Kyle Miller
e29d75a961
feat: have pp.proofs use for omission (#3241)
By having the `pp.proofs` feature use `⋯` when omitting proofs, when
users copy/paste terms from the InfoView the elaborator can give an
error message explaining why the term cannot be elaborated.

Also adds `pp.proofs.threshold` option to allow users to pretty print
shallow proof terms. By default, only atomic proof terms are pretty
printed.

This adjustment was suggested in PR #3201, which added `⋯` and the
related `pp.deepTerms` option.
2024-02-15 21:49:41 +00:00
Kyle Miller
c394a834c3
feat: extract delabAppCore, define withOverApp, and make over-applied projections pretty print (#3083)
To handle delaborating notations that are functions that can be applied
to arguments, extracts the core function application delaborator as a
separate function that accepts the number of arguments to process and a
delaborator to apply to the "head" of the expression.

Defines `withOverApp`, which has the same interface as the combinator of
the same name from std4, but it uses this core function application
delaborator.

Uses `withOverApp` to improve a number of application delaborators,
notably projections. This means Mathlib can stop using `pp_dot` for
structure fields that have function types.

Incidentally fixes `getParamKinds` to specialize default values to use
supplied arguments, which impacts how default arguments are delaborated.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-01-10 13:24:28 +00:00
Gabriel Ebner
742d053a97 fix: respect pp.raw in interactive .ofGoal
Fixes #2175
2023-03-30 17:19:35 -07:00
Rishikesh Vaishnav
561e404fe4
feat: make go-to-definition on a typeclass projection application go to the instance(s) (#1767) 2023-01-19 09:10:01 +00:00
Wojciech Nawrocki
f5531c2a11 feat: add context and term data to goals 2023-01-13 17:13:02 -08:00
Gabriel Ebner
eeab2af7ae fix: remove Inhabited Environment instance 2022-12-21 20:08:08 +01:00
Sebastian Ullrich
6169435259 refactor: consolidate MessageData constructors into lazy formatting with infos 2022-12-07 19:16:25 +01:00
Ed Ayers
7fabdf95d6 refactor: diffTag → diffStatus
Co-authored-by: Gabriel Ebner <gebner@gebner.org>
2022-10-06 13:06:31 -07:00
E.W.Ayers
506abff532 fix: replace highlight with diffTag 2022-10-06 13:06:31 -07:00
Ed Ayers
2a6697e077
feat: goal-diffs (#1610) 2022-09-24 11:46:11 +02:00
Gabriel Ebner
90f92c3a9e fix: use delabAppExplicit for tooltips 2022-08-25 18:38:21 +02:00
Gabriel Ebner
e9545a426f refactor: RpcEncodable 2022-08-10 06:31:46 -07:00
E.W.Ayers
2fe933cdf5 refactor: make SubExpr.Pos a definition
Instead of an abbreviation. It is easier to understand
Pos operations in terms of 'push' and 'pop' rather than
through arithmetic.
2022-06-17 17:47:51 -07:00
E.W.Ayers
367bde3601 chore: revert "refactor: replace InfoWithCtx with ExprWithCtx"
This reverts commit db342793d53c986b8794084196552c33711f9091.
2022-06-13 16:32:01 -07:00
E.W.Ayers
f64cb95eca refactor: replace InfoWithCtx with ExprWithCtx
This is potentially controversial. There are still some [todo]s that need sorting.
2022-06-13 16:32:01 -07:00
Wojciech Nawrocki
351be06a21 feat: ppExprTagged RPC call 2022-06-13 16:32:01 -07:00
E.W.Ayers
1785ab142e refactor: move Lean.PrettyPrinter.Delaborator.SubExpr to Lean.SubExpr
This is because SubExpr has uses outside the Delaborator.

Closes #1183
2022-06-03 12:38:14 -07:00
Wojciech Nawrocki
737e872ee0 feat: set tagAppFns in explicit exprToInteractive 2022-05-31 00:07:56 +02:00
Wojciech Nawrocki
cd47c30e47 chore: review fixes 2022-05-31 00:07:56 +02:00
Wojciech Nawrocki
e555490ee2 feat: store subexpression positions 2022-05-31 00:07:56 +02:00
Wojciech Nawrocki
72c4717055 chore: remove dead code 2022-05-12 08:38:09 -07:00
Wojciech Nawrocki
11e10459bb refactor: move function to PrettyPrinter 2022-05-12 08:38:09 -07:00
Wojciech Nawrocki
81b1f1df6e refactor: unify format functions 2022-05-12 08:38:09 -07:00
Leonardo de Moura
726b735c6d fix: using invalid name generator at ContextInfo.runMetaM
Already used `MVarId`s were being "reused" potentially creating cyclic
metavar assignment. See issue #1031 for an example.

closes #1031
2022-04-15 18:42:34 -07:00
Leonardo de Moura
55989c25fc chore: remove unnecessary args 2022-04-07 18:19:15 -07:00
Leonardo de Moura
12e2a79170 chore: fix codebase after removing auto pure 2022-02-03 18:08:14 -08:00
Leonardo de Moura
bac91b9b5b chore: remove arbitrary 2022-01-15 12:14:27 -08:00
Gabriel Ebner
546bb8f053 fix: widgets: do not highlight entire expression in popup 2021-12-21 21:54:51 +01:00
Sebastian Ullrich
80c3d88e3e refactor: optimize critical import path 2021-12-06 08:05:24 -08:00
Wojciech Nawrocki
e843fb7ca5 fix: widget messages 2021-10-17 10:01:23 +02:00
Wojciech Nawrocki
07f99eba73 fix: use local context from Info node in widgets 2021-10-04 21:09:44 +02:00
Wojciech Nawrocki
f454850c70 fix: actually specify opts-per-pos 2021-10-02 09:55:55 +02:00
Wojciech Nawrocki
0d35cf3bb8 feat: allow future additions to CodeWithInfos tags 2021-08-24 08:57:41 -07:00
Wojciech Nawrocki
03dbfaea03 chore: remove ExprWithCtx 2021-08-24 08:57:41 -07:00
Wojciech Nawrocki
568cc3cf11 refactor: consistent naming of widget modules 2021-08-24 08:57:41 -07:00
Renamed from src/Lean/Widget/ExprWithCtx.lean (Browse further)