Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow annotation with different styles #76

Open
hellow554 opened this issue May 26, 2023 · 3 comments
Open

Allow annotation with different styles #76

hellow554 opened this issue May 26, 2023 · 3 comments
Labels
rewrite-todo Things to fix during the crate rewrite

Comments

@hellow554
Copy link

hellow554 commented May 26, 2023

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
Copy link
Owner

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

@zesterer zesterer added the rewrite-todo Things to fix during the crate rewrite label May 26, 2023
@hellow554
Copy link
Author

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
Copy link
Owner

zesterer commented May 30, 2023

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:

  • Made the code more modular, easier to understand, and easy to extend
  • Support more advanced layouting options
  • Rewrite the Cache/Source system to be more efficient, to generalise better, and generally be less of a nuisance.
  • Use byte offsets instead of character offsets by default (with an option to convert the latter to the former)
  • Figure out how to do colour and other formatting 'properly'. Right now we just assume that labels are strings and have text formatting be applied with ANSI escape codes by the user. The problem with this is that we can't easily do anything to customise that formatting because it happens before we have access to it. The best we can do is to strip it out with an ANSI stripper, but that's not particularly useful

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rewrite-todo Things to fix during the crate rewrite
Projects
None yet
Development

No branches or pull requests

2 participants