Skip to content

Commit 6c3bb40

Browse files
committed
Add inspect demo for diagnostics, hover, and go-to-definition
Walks through a natural workflow: write a theorem with sorry, see the warning, hover on double to check its signature, jump to its definition to read the implementation, then come back and replace sorry with rfl to complete the proof.
1 parent 3db972e commit 6c3bb40

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

demos/lean/Demos.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
import Demos.Inspect
12
import Demos.Navigation
23
import Demos.TraceSearch

demos/lean/Demos/Inspect.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def double (n : Nat) : Nat := n + n

demos/tapes/inspect.tape

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Demo: Inspecting code — diagnostics, hover, go-to-definition
2+
#
3+
# Shows a natural workflow: write a theorem, see a warning,
4+
# investigate with hover and go-to-definition, then fix it.
5+
6+
Require nvim
7+
8+
Output demos/output/inspect.gif
9+
Output demos/output/inspect.mp4
10+
11+
Source demos/tapes/setup.tape
12+
13+
Hide
14+
Type "just nvim" Enter
15+
Sleep 3s
16+
Source demos/tapes/helpers.tape
17+
# Add a border to hover floats so they stand out
18+
Type ":lua vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded' })" Enter
19+
Type ":e demos/lean/Demos/Inspect.lean" Enter
20+
Sleep 500ms
21+
Type "gg"
22+
Sleep 30s
23+
Ctrl+l
24+
Sleep 2s
25+
Show
26+
Sleep 2s
27+
28+
# Start writing a theorem about double
29+
Type "Go" Enter
30+
Type@40ms "theorem double_zero : double 0 = 0 := by"
31+
Sleep 2s
32+
33+
# Try sorry — it works but leaves a warning
34+
Enter
35+
Type@40ms "sorry"
36+
Sleep 3s
37+
Escape
38+
39+
# There's a warning — jump to it
40+
Type "]d"
41+
Sleep 2s
42+
43+
# What is `double` exactly? Hover to find out.
44+
Type "0f:w"
45+
Sleep 500ms
46+
Type "K"
47+
Sleep 4s
48+
49+
# Jump to the definition to see the implementation
50+
Type "gd"
51+
Sleep 3s
52+
53+
# Now we know it's n + n, so rfl should work. Go back and fix.
54+
Ctrl+o
55+
Sleep 1s
56+
Type "/sorry" Enter
57+
Type@40ms "ciwrfl"
58+
Escape
59+
Sleep 4s
60+
61+
# End card
62+
Hide
63+
Type@0ms ":lua DEMO.end_card{' Inspecting code:', '', ' ]d / [d next / previous diagnostic', ' K hover documentation', ' gd go-to-definition', '', ' See :h lean for more.'}" Enter
64+
Show
65+
Sleep 4s
66+
67+
Type ":qa!" Enter
68+
Sleep 500ms

0 commit comments

Comments
 (0)