asai icon indicating copy to clipboard operation
asai copied to clipboard

💅 Implement a handler based on grace

Open favonia opened this issue 2 years ago • 8 comments

@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.

favonia avatar Oct 18 '23 13:10 favonia

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 avatar Oct 18 '23 14:10 johnyob

@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:

favonia avatar Oct 18 '23 16:10 favonia

@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:

favonia avatar Oct 21 '23 13:10 favonia

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 avatar Oct 23 '23 15:10 johnyob

@johnyob I am glad that it's now ready! This issue is no longer blocked.

favonia avatar Jan 17 '24 11:01 favonia

@johnyob I believe the only things to do are

  1. 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
  2. Write a new section in the tutorial to show how to use the bridge.

Here are some details:

  1. Do "Help" and "Note" correspond to "Hint" and "Info". This is Rust v.s. LSP and we stole the LSP terminology.
  2. The explanation will be the message.
  3. 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...

favonia avatar Jan 17 '24 12:01 favonia

@johnyob Question: an asai diagnostic comes with a stack backtrace. Should them be "secondary" labels, or standalone diagnostics by themselves?

favonia avatar Jan 17 '24 17:01 favonia

@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.)

favonia avatar Aug 12 '24 18:08 favonia