Rust kak-tool template

Hi,

I’ve been entertaining one extension idea for Kakoune for a while and would like to share result. A quick-start template for mini-tools (in Rust):

The idea is that Kakoune shell scripting is great, but it is shell scripting. Often it blocks UI or just simply is too complex to express in shell scripting. This is a template that is non-blocking and also starts fast. This can be used to integrate more complex logic into Kakoune.

I’ve added two examples - first - a simple pong in Session/Client context and second with a Rust-opened FIFO so that buffer can be opened in fifo mode later.

It’s quite basic, and I’m using something for (not-yet-published) universal searcher. Hope someone fill find it useful.

1 Like

hi

i think it’d be better to have a single executable custom build for running the command given in argv, and it does the forking by itself, rather than have that functionality in every tool

would make each following tool slightly simpler, and also if one wishes to use them outside of kakoune, for example from command line or in a regular shell script, they don’t have to deal with a fork they don’t actually need

This template is an extract from kak-univ-search utility (pretty much Peneira clone, because I dislike Lua :stuck_out_tongue:) with communication handled by FIFO.

(Note that I just pushed the code for inspection, as it’s nowhere near shareable state).

kak-univ-search is nice because it doesn’t flicker on updated (as opposed to :edit! -fifo) but then I figured that having a one executable per use is actually simpler for some class of utilities (like text and replace or ripgrep with a specific prefix). The overhead is so low that it is almost invisible and allows for complex interactions with Kakoune itself.

It’s a %sh{} alternative - the same results can be achieved using shell scripts but for some Rust is more ergonomic than shell script :slight_smile:

1 Like