ai-cli icon indicating copy to clipboard operation
ai-cli copied to clipboard

feat: add syntax highlighting

Open okwasniewski opened this issue 1 year ago • 5 comments

Summary

This PR adds syntax highlighting feature

Demo:

CleanShot 2024-02-19 at 17 37 35@2x

Test plan

Ask AI for a message that can contain codeblock, for example: show me swift class that stores a counter state and has methods to increment and decrement

TODO

  • [ ] Add option to disable syntax highlighting

okwasniewski avatar Feb 19 '24 16:02 okwasniewski

I was wondering if we need an option to disable syntax highlighting - I've added it as TODO by Im not sure if it will be useful

okwasniewski avatar Feb 19 '24 16:02 okwasniewski

@okwasniewski perhaps we could keep the opening and closing ``` and just colorize the content? That would make it stand out more, and also be easier for copy pasting to markdown (a minor thing).

mdjastrzebski avatar Feb 20 '24 09:02 mdjastrzebski

Ugh, I'm sorry @mdjastrzebski I forgot about this PR.. I guess by looking at https://github.com/callstack/ai-cli/pull/34 this solution wouldn't be valid after Ink get's merged. Should I close the PR and later on reimplement it?

okwasniewski avatar Mar 17 '24 18:03 okwasniewski

No worries @okwasniewski.

We've added ink to be able to implement streaming responses, and overall better UI in the near future.

The chalk code in your PR might not work directly either ink, but on the other hand it also seems to use chalk, so perhaps there is some easy way to adapt it.

mdjastrzebski avatar Mar 18 '24 07:03 mdjastrzebski

@okwasniewski Ink implemenation is stable now. If you have some free capacity, please adjust the PR to the current codebase.

mdjastrzebski avatar Apr 02 '24 11:04 mdjastrzebski

I'm sorry I won't find time to finish this soon and don't want to block implementing this feature. If anyone else wants to add this feature feel free to use my implementation as a base reference

okwasniewski avatar Jul 30 '24 08:07 okwasniewski