Zulip Chat Archive
Stream: lean4
Topic: rfc: three suggestions to improve the web editor
Kenny Lau (Oct 08 2025 at 08:18):
I frequently use the web editor to make and review mathlib PR's because, well, it takes 2 minutes to download mathlib cache and sometimes my vscode lean just gets stuck for no reason (I think it's because I have too many files open), so I've noticed three ways that the web editor maybe can be improved:
- If I have a long file open and I edit the first part, every edit seems to be processed separately and each edit has to be processed before the next edit is processed, which effectively means that the entire file afterwards is updated for 20 times before everything starts working again, and ironically hitting the refresh button and letting it start again is faster. I have no clue actually how easy or hard this is to address.
- To make it more like mathlib, maybe we can enable a feature where it will stop automatically accept unprovided vavriables, and also unspecified universe. (See example below)
- Right-clicking an existing theorem and clicking "Go to definition" brings me to the doc page, which is helpful, but it doesn't bring me to the section automatically, because the anchorings are done differently between the editor (by line) and the doc pages (by name). (See example below)
Kenny Lau (Oct 08 2025 at 08:21):
Example for 2:
theorem foo (α : Type u) : x = x := rfl
-- This would not be accepted in Mathlib because `u` and `x` are not defined.
-- So this should throw an error in the web editor.
Example for 3:
import Mathlib.Logic.Function.Defs
#check Function.Bijective -- right click -> go to definition
Henrik Böving (Oct 08 2025 at 08:44):
- To make it more like mathlib, maybe we can enable a feature where it will stop automatically accept unprovided vavriables, and also unspecified universe. (See example below)
Add set_option autoImplicit false to the top if you want that.
Kenny Lau (Oct 08 2025 at 08:45):
thanks!
Eric Wieser (Oct 08 2025 at 09:32):
Regarding 3, is there any hope of making the "peek definition" functionality work? Right now it shows a box with the filename and line number, but it's unable to load the actual file content
Henrik Böving (Oct 08 2025 at 11:02):
I think that should definitely be doable in theory yes.
Kenny Lau (Oct 08 2025 at 19:35):
Kenny Lau said:
- each edit has to be processed before the next edit is processed
so I assume 1 is impossible?
Shreyas Srinivas (Oct 08 2025 at 19:45):
One can get all this with mathlib by opening it in codespaces or Ona (formerly gitpod). I hope the web editor stays as it is; as a scratchpad where one can use all Lean features by default including autoImplicits. The third point is worth filing a bug report about I guess.
Eric Wieser (Oct 08 2025 at 21:23):
Arguably import Mathlib is not any more a Lean feature than defaulting to autoImplicit false; both are a lakefile decision
Kenny Lau (Oct 08 2025 at 21:24):
Shreyas Srinivas said:
I hope the web editor stays as it is
for 2 i explicitly said "enable a feature", so like a button on the top that say "☐ mathlib mode"
Eric Wieser (Oct 08 2025 at 21:25):
Which I guess would also turn on the mathlib linters?
Kenny Lau (Oct 08 2025 at 21:25):
Actually, we can implement 2 today! it's via the example feature
we can just put an example that says "mathlib mode"
Eric Wieser (Oct 08 2025 at 21:26):
We could also implement it in the "latest mathlib" drop-down, since each choice is essentially choosing a lakefile
Kenny Lau (Oct 08 2025 at 21:26):
and that will change the whole file to:
import Mathlib
set_option autoImplicit false
universe u
-- code goes here...
#lint
Eric Wieser (Oct 08 2025 at 21:27):
That doesn't turn on the mathlib style linters
Kenny Lau (Oct 08 2025 at 21:27):
ah, the 'syntax linters', right
Kenny Lau (Oct 08 2025 at 21:28):
yeah i guess have an option on the bottom of the list that says "latest mathlib + mathlib mode"
Jon Eugster (Oct 13 2025 at 22:54):
Kenny Lau said:
- Right-clicking an existing theorem and clicking "Go to definition" brings me to the doc page, which is helpful, but it doesn't bring me to the section automatically, because the anchorings are done differently between the editor (by line) and the doc pages (by name). (See example below)
I remember when I implemented that I gave up on the jumping to the right section because, I think monaco only exposed something line "file X, line 77" instead of the declaration name and the doc-gen pages didn't have any api to open "whatever is on line 77 of that file".
Regarding "peek definitons", there might be a chance to get that working if all bugs in the part which translates URIs to file names on disk are eliminated, but that's a rather fiddly matter, I think.
Jon Eugster (Oct 13 2025 at 22:57):
- I would make a guess that there might be some RPC-calls/notifications which might need to be called to interrupt the Lean server. Maybe these need to be triggered explicitely by the monaco editor?
Jon Eugster (Oct 13 2025 at 23:06):
- Feel free to PR any examples, it should be as easy as just adding a .lean file to the "mathlib" project. There are instructions on the lean4web repo.
In theory each project should also respect the options set in it's lakefile, so one could disable autoimplicits there just like mathlib does. However, that part is as fiddly as what's mentioned before, so it's likely broken again (basically some part of the lean4-vscode extension or lake does require that a file exists on disk without much reason. It will still work if the file doesn't exist, its just been decided that in that case no options from the lakefile will be applied).
(side note: Also, I personally think disabling auto-imolicits is a bad choice, they are an deliberate feature of Lean. And especially since that feature got added where autoimplicits are displayed by vscode/monaco its also easier to spot them)
Last updated: Dec 20 2025 at 21:32 UTC