Kakpipe: easy executing external utilities inside kakoune with colored output

Hi there,

I just pushed kakpipe a new utility written in async rust to easily launch external program and see the result in a fifo buffer with colored output.

Nothing really fancy here as there was already the excellent kak-ansi plugin. It just works slightly differently by spawning the command, remove ansi codes before writing to fifo and serve range-specs definitions concurrently through a unix socket. The kakscript command itself is just reduced to one line.

Regards.

5 Likes

Not sure if you know this, but kak-ansi will already work on fifos if enabled with ansi-enable, incrementally adding ANSI ranges (also, it is automatically enabled for fifos created by piping to kak). It does this by hooking BufReadFifo.

Yes, and I even look at your code before also using BufReadFifo :wink:

kakpipe was producing range-specs faster than kakoune could consume them, so I ended up with holes in the coloring, so I just ended up using the upper limit of BufReadFifo selection range to serve range-specs up to that point and wait for kakoune to ask the remaining when ready.

kak-ansi was already working perfectly, but didn’t want to write kakscript boilerplate each time I wanted to launch a command in a fifo.

kakpipe was mainly an experience to write plugins in rust that encapsulate all the details. the kakscript is just one line. Apart from that, the implementation is slightly different. I think kak-ansi can’t work on read-only buffers, whereas kakpipe can, because it doesn’t touch the content. kak-ansi is 23k and you can’t beat that, or perhaps in assembly. kakpipe is several MB but embed a async server instead of writing and sourcing files.