Open favonia opened 3 weeks ago
I was going to write a response here that something like a handler combinator thingy is the more natural way to proceed, but you beat me to it :)
@kentookura Are you claiming that with these three combinators you can already implement the features you wanted trivially?
Yes, I think so
One thing that I want to point out is that when implementing a language server, it is important that an empty list of diagnostics gets pushed when a computation that previously failed now succeeded. Right now I am checking this manually, but maybe this is an interesting factor when designing this.
Another thing is that diagnostics need a URI to be published to, and a computation might raise diagnostics for many files. I am handling this by
source
argument(Lsp.Uri.t, diagnostic list) Hashtbl.t
that gets populated by emit
and fatal
: I am inspecting the loctext of the diagnostic and creating an Lsp.Uri.t
from it.This is not enough, though:
Say that evaluating file A
previously failed and had a diagnostic pushed to it. Running the evaluator again now succeeds, but now I need to know that A
failed the last time in order to push an empty list to clear the diagnostics, so I need to track some state.