hellerve / sbcli

A REPL for my SBCL needs
GNU General Public License v3.0
94 stars 13 forks source link

Syntax Highlighting using pygmentize #14

Closed hellerve closed 3 years ago

hellerve commented 4 years ago

This PR adds optional syntax highlighting by shelling out to pygmentize. I don’t love that approach, but it is pretty simple, and I didn’t want to go through the pains of doing syntax analysis myself for now.

Cheers

vindarel commented 4 years ago

That would be great!

There's a hardcoded path to pygmentize in maybe-highlight.

This "which" function in CL might help: https://github.com/eudoxia0/which/blob/master/src/which.lisp

hellerve commented 4 years ago

Ah, I was meaning to use *pygmentize* there, my bad. I think the user could use which if they need to, but since they’re required to provide the path themselves we don’t need to figure it out!

vindarel commented 4 years ago

It works fine. Nice.

Now for a better experience out of the box, I would mention "which" (I like it, it found my pygmentize in a virtual environment), add a "-h" command line argument, add a "--color" one,… this makes sbcli grow, but not necessarily by much. CLI arguments are stored in sb-ext:*posix-argv*. No need of "real" CLI args parsing yet.

hellerve commented 4 years ago

All fair points. Would --color use which to fill *pygmentize* automatically? Or would setting it add another layer of enabling/disabling coloring?

vindarel commented 4 years ago

indeed it could. The "do what I mean" behavior for me is:

(we can also first mention "which" in the README as a nice trick, and do the rest in a following commit)

hellerve commented 3 years ago

I added the note for now, and will merge as-is. If we need which capabilites later on, we know where to look! Thanks again!