Commit 90eb615
authored
feat: editor decorations (#585)
This PR adds several new editor decorations.
### Error and warning gutter decorations
To resolve the issue that warnings and errors can sometimes be a bit
difficult to spot, especially when the corresponding diagnostic squiggly
is small, this PR adds a system of gutter decorations to make errors and
warnings much more visible.

The circled error and warning symbols denote the line where an error or
a warning starts, i.e. where the squiggly is displayed. A red vertical
line denotes the *full range* of the error, i.e. the range in which the
error is displayed under 'Messages' in the InfoView. The red line bends
to the right whenever a full error range ends in that line of code.
Single line errors are displayed without a red line.
These gutter decorations can be disabled using the 'Lean4: Show
Diagnostic Gutter Decorations' setting. When the gutter icons of the
Error Lens extension are enabled, the gutter decorations of the Lean 4
VS Code extension are disabled.
Once this PR is merged, this feature will be available in all Lean 4
versions.
### 'Unsolved goals' markers
To resolve the issue that it can sometimes be a bit difficult to tell
where one should continue typing in a proof, this PR adds an end-of-line
editor decoration that is displayed in the line where the full range of
an 'unsolved goals' error ends.

The 'unsolved goals' markers can be disabled using the 'Lean 4: Show
Unsolved Goal Decoration' setting.
This feature needs language server support, so it will only be active
for Lean versions that include the companion PR at
leanprover/lean4#7366.
### Goals accomplished!
To re-introduce some positive reinforcement into Lean 4 after the 'Goals
accomplished!' message from Lean 3 was removed due to often being
confusing in Lean 4, this PR adds a new 'Goals accomplished!' mechanism
when a theorem or a `Prop`-typed `example` has been proven.

When a theorem or a `Prop`-typed `example` contains no errors or
`sorry`s anymore, two blue checkmarks appear next to the start of the
declaration as a gutter decoration. Additionally, a 'Goals
accomplished!' message appears under 'Messages' in the InfoView. The
'Goals accomplished!' message does not appear in 'All Messages' and is
not displayed with a squiggly line in the editor.
The 'Goals accomplished!' gutter decoration can be configured or
disabled using the 'Lean 4: Goals Accomplished Decoration Kind' setting.
In addition to the default double checkmark decoration pictured above,
this PR adds the following additional styles for the gutter decoration:
- Circled checkmark:

- Octopus:

- Tada:

This feature needs language server support, so it will only be active
for Lean versions that include the companion PR at
leanprover/lean4#7366.
### Technical notes
- We intend to test this implementation for the 'unsolved goals' markers
and 'Goals accomplished!' in core before v4.19.0-rc1 to iron out any
remaining issues.
- All gutter decorations are implemented using .svgs, which is the only
API that VS Code provides to display things in the gutter. Since there
are lots of different cases to consider for the red vertical error range
lines, as well as for light and dark themes, this PR ships 56 .svg files
in total.
- The design language of the red lines for the error range gutter
decorations is deliberately not perfectly unambiguous. For example, when
multiple full error ranges overlap, it isn't clear which error range is
terminated by the line bending to the right. The design in this PR is
the best I could come up with for the limited size of the gutter without
introducing too much visual complexity or noise.
- The task gutter had to be rewritten entirely for this PR, including
the progress bar code.
- Since the line where the full range of an 'unsolved goals' error ends
is relatively unstable as the document is being edited, this PR
implements an edit delay of 3000ms for 'unsolved goals' markers, so that
they do not constantly jump around while editing the document.
- The 'unsolved goals' markers use an emoji (specifically the 'Hammer
and wrench' emoji U+1F6E0) instead of an icon. The reason for this is
that VS Code's decoration API appears to be pretty broken for
end-of-line icons and fails to vertically center them correctly.
- None of these decorations have an associated hover to explain the
semantics of each decoration. The reason for this is that VS Code
doesn't support gutter decoration hovers and for end-of-line
decorations, it pollutes the hover of every hover in the whole line with
the hover message of the end-of-line decoration.
- This PR includes the client-side for the protocol extensions defined
at leanprover/lean4#7366.1 parent c4d12fc commit 90eb615
File tree
73 files changed
+9822
-150
lines changed- lean4-infoview-api
- src
- lean4-infoview
- src/infoview
- vscode-lean4
- media/diagnostic-gutter-icons
- src
- utils
- webview
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
73 files changed
+9822
-150
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
14 | 28 | | |
15 | 29 | | |
16 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
5 | 10 | | |
6 | 11 | | |
7 | 12 | | |
| |||
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
16 | | - | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
418 | | - | |
| 418 | + | |
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
| 422 | + | |
423 | 423 | | |
424 | | - | |
| 424 | + | |
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 3 | + | |
10 | 4 | | |
11 | | - | |
| 5 | + | |
12 | 6 | | |
13 | 7 | | |
14 | 8 | | |
| |||
135 | 129 | | |
136 | 130 | | |
137 | 131 | | |
138 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
139 | 135 | | |
140 | 136 | | |
141 | 137 | | |
| |||
145 | 141 | | |
146 | 142 | | |
147 | 143 | | |
148 | | - | |
| 144 | + | |
| 145 | + | |
149 | 146 | | |
150 | 147 | | |
151 | 148 | | |
| |||
159 | 156 | | |
160 | 157 | | |
161 | 158 | | |
162 | | - | |
| 159 | + | |
163 | 160 | | |
164 | 161 | | |
165 | 162 | | |
| |||
247 | 244 | | |
248 | 245 | | |
249 | 246 | | |
250 | | - | |
251 | | - | |
| 247 | + | |
| 248 | + | |
252 | 249 | | |
253 | 250 | | |
254 | 251 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments