lean4web icon indicating copy to clipboard operation
lean4web copied to clipboard

Go-to-def

Open joneugster opened this issue 1 year ago • 8 comments

Would be nice to have go-to-def open the correct page of the docs: https://leanprover-community.github.io/mathlib4_docs/

joneugster avatar Aug 08 '24 21:08 joneugster

2b799f7bad8d2c396c5ce7622751edeec2309c83 implements a go-to-def functionality.

  • [ ] It just opens the corresponding doc-gen page, but is missing #My.Lean.Declaration in the URL.
  • [ ] There is a console error associated with it: Ctrl+Hover over any definition to see it.
  • [x] Have to click "Cancel" 4-5 times :(

joneugster avatar Aug 09 '24 21:08 joneugster

@joneugster I still have the Have to click "Cancel" 4-5 times :( bug on macOS but not on Linux. Also the console error when doing Ctrl+Hover over any definition is also present in lean4monaco demo project, so this seems not related to the go-to-def functionality.

tautastic avatar Mar 07 '25 11:03 tautastic

It is related (not in the custom gotodef, but in monaco's gotodef), but youre right, ctrl-hiver should be fixed in lean4monaco. (sometimes the issues between lean4monaco and lean4web arent perfectly separated)

joneugster avatar Mar 07 '25 12:03 joneugster

Also doing right-click then Go To References shows many References that seem valid but trying to view any of them that are not part of the current file throws a similar error. Could we allow lean4monaco access to the .lake/packages directory. Or maybe the first question is: do we want to? If not then maybe we should try to remove the cases where these kinds of errors occur. Also same issue for right-click then peek > peek definition and peek > peek type definition

tautastic avatar Mar 07 '25 14:03 tautastic

@joneugster A quick temporary fix would be to open the source code instead of the docs, since we have the line number we can link directly to what was clicked on. See the code changes here: https://github.com/tautastic/lean4web/commit/5ce888662868f5885fb5051c74b24a8e7c402510

tautastic avatar Mar 07 '25 17:03 tautastic

I think when I implemented this I decided that opening the correct doc page without line numer is nicer than opening the source. But that's probably just personal taste. Ofc getting the relevant info to open the right doc would be ideal

joneugster avatar Mar 07 '25 19:03 joneugster

Is the desired behavior to improve the current solution or to get the "go-to" and "peek" stuff to work just like in vscode? I mean the mathlib files are on the server we could just open them in a new editor tab.

tautastic avatar Mar 08 '25 09:03 tautastic

That could be a nice feature, I suppose 👍

joneugster avatar Mar 08 '25 18:03 joneugster