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

Display code snippets with syntax highlighting #4

Closed
repi opened this issue Aug 19, 2023 · 4 comments
Closed

Display code snippets with syntax highlighting #4

repi opened this issue Aug 19, 2023 · 4 comments

Comments

@repi
Copy link

repi commented Aug 19, 2023

Would be nice to show the code diffs in the "Usage details" window with colored syntax highlighting to more easily be able to read it, esp. as one may be scanning through quite a lot of diffs when triaging with this tool. Though not a high priority as would just be a "nice to have".

Believe seen some Rust syntax highlighting crate that may be easy to integrate

@davidlattimore
Copy link
Collaborator

Yes, syntax highlighting would be nice - provided whatever provides it isn't too heavy-weight. So something just based on tokens, not full rust-analyzer :) I'm assuming you mean the code snippets BTW - Cackle doesn't display any code diffs currently. It does display diffs of cackle.toml when previewing an automatic edit of the configuration file.

@repi
Copy link
Author

repi commented Aug 19, 2023

sorry yes mean the snippets, like this:

image

@davidlattimore
Copy link
Collaborator

Thinking about syntax highlighting some more, I'm unsure that a syntax-highlighting library would provide much beyond what a lexer already provides. Cackle already depends on rustc-ap-rustc_lexer, so we could take the output of that then assign different colours to different categories of tokens.

@davidlattimore davidlattimore changed the title Display code diff with syntax highlighting Display code snippets with syntax highlighting Aug 19, 2023
@davidlattimore
Copy link
Collaborator

I just added some basic syntax colouring. I didn't put too much thought into the colours, so if you have opinions on the colours, feel free to tweak and send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants