zesterer / ariadne

A fancy diagnostics & error reporting crate
https://crates.io/crates/ariadne
MIT License
1.74k stars 76 forks source link

Allow annotation with different styles #76

Open hellow554 opened 1 year ago

hellow554 commented 1 year ago

What I want to achieve:

Currently, there's only a way to underline some text with fancy utf-8 underscores.
I want something similar to this:

error[E0061]: this function takes 1 argument but 3 arguments were supplied
 --> src/main.rs:2:5
  |
2 |     std::mem::transmute(3, 3, 4);
  |     ^^^^^^^^^^^^^^^^^^^    -  - unexpected argument of type `{integer}`
  |                            |
  |                            unexpected argument of type `{integer}`

A possible way to achieve that:

My thought would be adding a with_style option to a Label and maybe restrict those to Underscore, Wiggly and Spiky (just making up names), where Underscore would be the default, Wiggly would use ~ and Spiky ^.

One thing to note would be, that those notation shouldn't be allowed to have a message associated with them?

What do you think?

zesterer commented 1 year ago

I would like to see this, and I hope the eventual refactor will cover this use-case!

hellow554 commented 1 year ago

I'm curious about the rewrite. Do you have anything particular in mind or anything done yet?

I'm not sure, but I'd like to help, cause I really like this library! <3

zesterer commented 1 year ago

I've unfortunately not made much progress. Most of Ariadne was written over a single night in a sort of fugue state some time ago. Needless to say, the internals reflect that. There are a few main goals I have for the rewrite:

I have some initial thoughts about the best approach for this.

I'm thinking that a good strategy would be to create a type-directed API that behaves sort of like a DOM, but specifically geared toward displaying error diagnostics.

That way, users can specify content and themeing independently of one-another and Ariadne turns into a sort of glorified document rendering engine. It would also allow for more 'alien' output formats: Ariadne could render diagnostics as HTML, JSON (for LSP), or any number of other formats.

As with most of these things, I tend to go through long periods of inactivity and then have a single night of hyperfocus and everything suddenly comes together. I'm hoping inspiration will strike me soon. Thanks for your comment, it's forced me to put some of my thoughts into words and now I'm thinking about it again!

Edit: I just noticed that you're interesting in helping. I'd really appreciate that! I've always found that collaborating with people is a great way to get my head to switch on and start doing stuff. Did you have any thoughts on all this?