forked from leanprover/lean4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: travelling auto-completion (leanprover#5257)
Fixes leanprover#4455, fixes leanprover#4705, fixes leanprover#5219 Also fixes a minor bug where a dot in brackets would report incorrect completions instead of no completions. --------- Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
- Loading branch information
1 parent
25f85e5
commit cc95a80
Showing
7 changed files
with
189 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
inductive Direction where | ||
| up | ||
| right | ||
| down | ||
| left | ||
|
||
-- It would be nice if this actually provided `up`, `right`, `down` and `left` in the future | ||
def foo : Direction := | ||
(.) | ||
--^ textDocument/completion |
3 changes: 3 additions & 0 deletions
3
tests/lean/interactive/completionBracketedDot.lean.expected.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{"textDocument": {"uri": "file:///completionBracketedDot.lean"}, | ||
"position": {"line": 8, "character": 4}} | ||
{"items": [], "isIncomplete": true} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Lean | ||
|
||
|
||
|
||
-- https://github.com/leanprover/lean4/issues/4455 | ||
def aaaaaaaa := 1 | ||
|
||
#eval ([1,2,3].map λ c => aaaaaaa).length | ||
--^ textDocument/completion | ||
|
||
|
||
|
||
-- https://github.com/leanprover/lean4/issues/4705 | ||
structure Bar where | ||
foobar : Nat | ||
|
||
structure Foo where | ||
x : Bar | ||
|
||
example (f : Foo) : Nat × Nat := | ||
⟨f.x.foobar, f.x.f⟩ | ||
--^ textDocument/completion | ||
|
||
example (b : Bar) : Nat × Nat := | ||
⟨b.foobar, b.f⟩ | ||
--^ textDocument/completion | ||
|
||
|
||
|
||
-- https://github.com/leanprover/lean4/issues/5219 | ||
structure ContinuousSMul (M X : Type) : Prop where | ||
structure ContinuousAdd (X : Type) : Prop where | ||
|
||
theorem Prod.continuousSMul {M X Y : Type} : ContinuousSMul M (X × Y) := ⟨⟩ | ||
|
||
theorem Prod.continuousAdd {X Y : Type} : ContinuousAdd (X × Y) := ⟨⟩ | ||
|
||
example : (ContinuousSMul Nat (Nat × Nat)) ∧ (ContinuousAdd (Nat × Nat)) := by | ||
exact ⟨Prod.continuousSMul, Prod.continuous⟩ | ||
--^ textDocument/completion | ||
|
||
example : True ∧ True := by | ||
exact ⟨trivial, True.in⟩ | ||
--^ textDocument/completion |
72 changes: 72 additions & 0 deletions
72
tests/lean/interactive/travellingCompletions.lean.expected.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{"textDocument": {"uri": "file:///travellingCompletions.lean"}, | ||
"position": {"line": 7, "character": 33}} | ||
{"items": | ||
[{"sortText": "0", | ||
"label": "aaaaaaaa", | ||
"kind": 21, | ||
"data": | ||
{"params": | ||
{"textDocument": {"uri": "file:///travellingCompletions.lean"}, | ||
"position": {"line": 7, "character": 33}}, | ||
"id": {"const": {"declName": "aaaaaaaa"}}}}], | ||
"isIncomplete": true} | ||
{"textDocument": {"uri": "file:///travellingCompletions.lean"}, | ||
"position": {"line": 20, "character": 20}} | ||
{"items": | ||
[{"sortText": "0", | ||
"label": "foobar", | ||
"kind": 5, | ||
"data": | ||
{"params": | ||
{"textDocument": {"uri": "file:///travellingCompletions.lean"}, | ||
"position": {"line": 20, "character": 20}}, | ||
"id": {"const": {"declName": "Bar.foobar"}}}}], | ||
"isIncomplete": true} | ||
{"textDocument": {"uri": "file:///travellingCompletions.lean"}, | ||
"position": {"line": 24, "character": 16}} | ||
{"items": | ||
[{"sortText": "0", | ||
"label": "foobar", | ||
"kind": 5, | ||
"data": | ||
{"params": | ||
{"textDocument": {"uri": "file:///travellingCompletions.lean"}, | ||
"position": {"line": 24, "character": 16}}, | ||
"id": {"const": {"declName": "Bar.foobar"}}}}], | ||
"isIncomplete": true} | ||
{"textDocument": {"uri": "file:///travellingCompletions.lean"}, | ||
"position": {"line": 38, "character": 45}} | ||
{"items": | ||
[{"sortText": "0", | ||
"label": "continuousAdd", | ||
"kind": 3, | ||
"data": | ||
{"params": | ||
{"textDocument": {"uri": "file:///travellingCompletions.lean"}, | ||
"position": {"line": 38, "character": 45}}, | ||
"id": {"const": {"declName": "Prod.continuousAdd"}}}}, | ||
{"sortText": "1", | ||
"label": "continuousSMul", | ||
"kind": 3, | ||
"data": | ||
{"params": | ||
{"textDocument": {"uri": "file:///travellingCompletions.lean"}, | ||
"position": {"line": 38, "character": 45}}, | ||
"id": {"const": {"declName": "Prod.continuousSMul"}}}}], | ||
"isIncomplete": true} | ||
{"textDocument": {"uri": "file:///travellingCompletions.lean"}, | ||
"position": {"line": 42, "character": 25}} | ||
{"items": | ||
[{"sortText": "0", | ||
"label": "intro", | ||
"kind": 4, | ||
"documentation": | ||
{"value": | ||
"`True` is true, and `True.intro` (or more commonly, `trivial`)\nis the proof. ", | ||
"kind": "markdown"}, | ||
"data": | ||
{"params": | ||
{"textDocument": {"uri": "file:///travellingCompletions.lean"}, | ||
"position": {"line": 42, "character": 25}}, | ||
"id": {"const": {"declName": "True.intro"}}}}], | ||
"isIncomplete": true} |