💅 Implement a handler based on grace
@johnyob has implemented the Rust-style diagnostic rendering at ~~https://gitlab.com/alistair.obrien/grace~~ https://github.com/johnyob/grace.
On the surface, it looks straightforward to adapt it into an asai diagnostic handler. Of course, the renderer will not satisfy our Level-2 display stability requirements, but I think we can implement a renderer with lower display stability requirements, which has the benefits of not relying solely on colors to highlight spans.
Hey 👋
Grace's current repository can be found here: https://github.com/johnyob/grace.
I'd recommend that asai doesn't use grace until early 2024 as I'm still (albeit slowly) working on grace's renderer.
@johnyob Thanks for the link---I just updated it.
If you are worried about the unstable API, asai is also very experimental. :sweat_smile: Also the core asai package will not depend on grace---we have a built-in terminal renderer and I planned to make the grace-backed handler a standalone package. Does that sound "safe" enough? OTOH, we can certainly wait until you feel the interface is more stable. :grin:
@johnyob Hi, I realized that you are using the package text but that package hasn't been updated for a while. More importantly, it currently does not support OCaml 5, but asai needs OCaml 5. Therefore, it's currently impossible to build a handler based on grace :cry:
Yes, in the initial release of grace, this dependency will be removed and the library will be suitable for OCaml 5. I intend to push this work at the beginning of January 2024
@johnyob I am glad that it's now ready! This issue is no longer blocked.
@johnyob I believe the only things to do are
- Write a function to convert an asai-diagnostic to this type: https://ocaml.org/p/grace/0.1.0/doc/Grace/Diagnostic/index.html#type-t
- Write a new section in the tutorial to show how to use the bridge.
Here are some details:
- Do "Help" and "Note" correspond to "Hint" and "Info". This is Rust v.s. LSP and we stole the LSP terminology.
- The explanation will be the message.
- The main location will be "primary", and its content is the library. The additional remarks with locations will be "secondary". The additional remarks without location will be notes.
I feel the other direction is also straightforward, except that Grace allows multiple primary labels. I wonder if I missed anything...
@johnyob Question: an asai diagnostic comes with a stack backtrace. Should them be "secondary" labels, or standalone diagnostics by themselves?
@johnyob Hi, I wonder if you think Grace is stable enough now, and whether you have any comment about the questions I asked above? (Sorry for the bothering but I am very interested in implementing the handler.)