Skip to content

Commit e8e49b2

Browse files
committedMay 30, 2024
[code] Show server status using LanguageStatusItem
We show server checking status and toolchain version using the new `LanguageStatusItem` UI. It is also possible to control using this UI whether the server is in continuous or lazy mode. Some more changes: - Added a new command to toggle the mode. - Show `coq-lsp` version info. More information about what the server is doing should be possible if the users want! (For example, we should show memory use, etc...)
1 parent fa39cad commit e8e49b2

25 files changed

+432
-93
lines changed
 

‎CHANGES.md

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
# unreleased
22
------------
33

4-
- Added new heatmap feature allowing timing data to be seen in the
5-
editor. Can be enabled with the `Coq LSP: Toggle heatmap`
6-
comamnd. Can be configured to show memory usage. Colors and
7-
granularity are configurable. (@Alizter and @ejgallego, #686,
8-
grants #681).
94
- new option `show_loc_info_on_hover` that will display parsing debug
105
information on hover; previous flag was fixed in code, which is way
116
less flexible. This also fixes the option being on in 0.1.8 by
@@ -132,19 +127,25 @@
132127
#697)
133128
- Always dispose UI elements. This should improve some strange
134129
behaviors on extension restart (@ejgallego, #708)
135-
- Support Coq meta-commands (Reset, Reset Initial, Back) They are
136-
actually pretty useful to hint the incremental engine to ignore
137-
changes in some part of the document (@ejgallego, #709)
130+
- [code] Added new heatmap feature allowing timing data to be seen in
131+
the editor. Can be enabled with the `Coq LSP: Toggle heatmap`
132+
comamnd. Can be configured to show memory usage. Colors and
133+
granularity are configurable. (@Alizter and @ejgallego, #686,
134+
grants #681).
135+
- [server] Support Coq meta-commands (Reset, Reset Initial, Back)
136+
They are actually pretty useful to hint the incremental engine to
137+
ignore changes in some part of the document (@ejgallego, #709)
138138
- JSON-RPC library now supports all kind of incoming messages
139139
(@ejgallego, #713)
140-
- New `coq/viewRange` notification, from client to server, than hints
141-
the scheduler for the visible area of the document; combined with
142-
the new lazy checking mode, this provides checking on scroll, a
143-
feature inspired from Isabelle IDE (@ejgallego, #717)
144-
- Have VSCode wait for full LSP client shutdown on server
140+
- [code/server] New `coq/viewRange` notification, from client to
141+
server, than hints the scheduler for the visible area of the
142+
document; combined with the new lazy checking mode, this provides
143+
checking on scroll, a feature inspired from Isabelle IDE
144+
(@ejgallego, #717)
145+
- [code] Have VSCode wait for full LSP client shutdown on server
145146
restart. This fixes some bugs on extension restart (finally!)
146147
(@ejgallego, #719)
147-
- Center the view if cursor goes out of scope in
148+
- [code] Center the view if cursor goes out of scope in
148149
`sentenceNext/sentencePrevious` (@ejgallego, #718)
149150
- Switch Flèche range encoding to protocol native, this means UTF-16
150151
code points for now (Léo Stefanesco, @ejgallego, #624, fixes #620,
@@ -154,7 +155,7 @@
154155
user navigates proofs (@Alidra @ejgallego, #722, #725)
155156
- `fcc`: new option `--diags_level` to control whether Coq's notice
156157
and info messages appear as diagnostics
157-
- Display the continous/on-request checking mode in the status bar,
158+
- [code] Display the continous/on-request checking mode in the status bar,
158159
allow to change it by clicking on it (@ejgallego, #721)
159160
- Add an example of multiple workspaces (@ejgallego, @Blaisorblade,
160161
#611)
@@ -173,6 +174,10 @@
173174
- [petanque] Return extra premise information: file name, position,
174175
raw_text, using the above support for reading .glob files
175176
(@ejgallego, #735)
177+
- [code] Display server status using the `LanguageStatusItem`
178+
facility, for now we display version and checking status
179+
information (moved from #721), and we also allow to toggle the
180+
checking mode from there (@ejgallego, #728)
176181

177182
# coq-lsp 0.1.8.1: Spring fix
178183
-----------------------------

‎README.md

+9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ and web native usage, providing quite a few extra features from vanilla Coq.
3939

4040
- [🎁 Features](#-features)
4141
- [⏩ Incremental Compilation and Continuous Document Checking](#-incremental-compilation-and-continuous-document-checking)
42+
- [👁 On-demand, Follow The Viewport Document Checking](#-on-demand-follow-the-viewport-document-checking)
4243
- [🧠 Smart, Cache-Aware Error Recovery](#-smart-cache-aware-error-recovery)
4344
- [🥅 Whole-Document Goal Display](#-whole-document-goal-display)
4445
- [🗒️ Markdown Support](#️-markdown-support)
@@ -89,6 +90,14 @@ restart your proof session where you left it at the last time.
8990
Incremental support is undergoing refinement, if `coq-lsp` rechecks when it
9091
should not, please file a bug!
9192

93+
### 👁 On-demand, Follow The Viewport Document Checking
94+
95+
`coq-lsp` does also support on-demand checking. Two modes are available: follow
96+
the cursor, or follow the viewport; the modes can be toggled using the Language
97+
Status Item in Code's bottom right corner:
98+
99+
<img alt="On-demand checking" height="572px" src="etc/img/on_demand.gif"/>
100+
92101
### 🧠 Smart, Cache-Aware Error Recovery
93102

94103
`coq-lsp` won't stop checking on errors, but supports (and encourages) working

‎compiler/output.ml

+14-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ let pp_diags fmt dl =
99
(* We will use this when we set eager diagnotics to true *)
1010
let diagnostics ~uri:_ ~version:_ _diags = ()
1111
let fileProgress ~uri:_ ~version:_ _progress = ()
12-
let perfData ~uri:_ ~version:_ _perf = ()
1312

1413
(* We print trace and messages, and perfData summary *)
1514
module Fcc_verbose = struct
@@ -24,26 +23,30 @@ module Fcc_verbose = struct
2423
let perfData ~uri:_ ~version:_ { Fleche.Perf.summary; _ } =
2524
Format.(eprintf "[perfdata]@\n@[%s@]@\n%!" summary)
2625

26+
let serverVersion _ = ()
27+
let serverStatus _ = ()
28+
2729
let cb =
28-
Fleche.Io.CallBack.{ trace; message; diagnostics; fileProgress; perfData }
30+
Fleche.Io.CallBack.
31+
{ trace
32+
; message
33+
; diagnostics
34+
; fileProgress
35+
; perfData
36+
; serverVersion
37+
; serverStatus
38+
}
2939
end
3040

3141
(* We print trace, messages *)
3242
module Fcc_normal = struct
3343
let trace _ ?extra:_ _ = ()
34-
let message = Fcc_verbose.message
35-
let perfData = Fcc_verbose.perfData
36-
37-
let cb =
38-
Fleche.Io.CallBack.{ trace; message; diagnostics; fileProgress; perfData }
44+
let cb = { Fcc_verbose.cb with trace }
3945
end
4046

4147
module Fcc_quiet = struct
42-
let trace _ ?extra:_ _ = ()
4348
let message ~lvl:_ ~message:_ = ()
44-
45-
let cb =
46-
Fleche.Io.CallBack.{ trace; message; diagnostics; fileProgress; perfData }
49+
let cb = { Fcc_normal.cb with message }
4750
end
4851

4952
let set_callbacks (display : Args.Display.t) =

‎controller/coq_lsp.ml

+32-15
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,52 @@ let rec process_queue ~delay ~io ~ofn ~state : unit =
4949
| Some (Cont state) -> process_queue ~delay ~io ~ofn ~state
5050

5151
let concise_cb ofn =
52+
let send_notification nt =
53+
Lsp.Base.Message.(Notification nt |> to_yojson) |> ofn
54+
in
55+
let diagnostics ~uri ~version diags =
56+
if List.length diags > 0 then
57+
Lsp.JLang.mk_diagnostics ~uri ~version diags |> send_notification
58+
in
5259
Fleche.Io.CallBack.
5360
{ trace = (fun _hdr ?extra:_ _msg -> ())
5461
; message = (fun ~lvl:_ ~message:_ -> ())
55-
; diagnostics =
56-
(fun ~uri ~version diags ->
57-
if List.length diags > 0 then
58-
Lsp.JLang.mk_diagnostics ~uri ~version diags |> ofn)
62+
; diagnostics
5963
; fileProgress = (fun ~uri:_ ~version:_ _progress -> ())
6064
; perfData = (fun ~uri:_ ~version:_ _perf -> ())
65+
; serverVersion = (fun _ -> ())
66+
; serverStatus = (fun _ -> ())
6167
}
6268

6369
(* Main loop *)
6470
let lsp_cb ofn =
71+
let send_notification nt =
72+
Lsp.Base.Message.(Notification nt |> to_yojson) |> ofn
73+
in
74+
let trace = LIO.trace in
6575
let message ~lvl ~message =
6676
let lvl = Fleche.Io.Level.to_int lvl in
6777
LIO.logMessageInt ~lvl ~message
6878
in
79+
let diagnostics ~uri ~version diags =
80+
Lsp.JLang.mk_diagnostics ~uri ~version diags |> send_notification
81+
in
82+
let fileProgress ~uri ~version progress =
83+
Lsp.JFleche.mk_progress ~uri ~version progress |> send_notification
84+
in
85+
let perfData ~uri ~version perf =
86+
Lsp.JFleche.mk_perf ~uri ~version perf |> send_notification
87+
in
88+
let serverVersion vi = Lsp.JFleche.mk_serverVersion vi |> send_notification in
89+
let serverStatus st = Lsp.JFleche.mk_serverStatus st |> send_notification in
6990
Fleche.Io.CallBack.
70-
{ trace = LIO.trace
91+
{ trace
7192
; message
72-
; diagnostics =
73-
(fun ~uri ~version diags ->
74-
Lsp.JLang.mk_diagnostics ~uri ~version diags |> ofn)
75-
; fileProgress =
76-
(fun ~uri ~version progress ->
77-
Lsp.JFleche.mk_progress ~uri ~version progress |> ofn)
78-
; perfData =
79-
(fun ~uri ~version perf ->
80-
Lsp.JFleche.mk_perf ~uri ~version perf |> ofn)
93+
; diagnostics
94+
; fileProgress
95+
; perfData
96+
; serverVersion
97+
; serverStatus
8198
}
8299

83100
let coq_init ~debug =
@@ -116,7 +133,7 @@ let lsp_main bt coqcorelib coqlib ocamlpath vo_load_path ml_include_path
116133
let json_fn = LIO.send_json Format.std_formatter in
117134

118135
let ofn response =
119-
let response = Lsp.Base.Response.to_yojson response in
136+
let response = Lsp.Base.Message.to_yojson response in
120137
LIO.send_json Format.std_formatter response
121138
in
122139

0 commit comments

Comments
 (0)