KakEdit
Make calls to $EDITOR
act upon an existing Kakoune instance.
Disclaimer
You should be using connect.kak.
Why
Mainly for fun and getting back at writing Go code. Also, leveraging client-server architecture for a text editor is still underrated.
Build & test
See Makefile
.
Usage
- Make sure
kak_session
andkak_client
environment variables are defined. - Run
kakedit PROGRAM
. This project was mainly written with broot(1) in mind.
This will run the given program and replace $EDITOR
(and $VISUAL
) with
something that will send an edit command to an existing Kakoune client.
Optionally, kakwrap
will look for a session name in a .kaksession
file located inside current directory.
How it works
kakedit
Start listening to a socket and run the program given as
argument. $EDITOR
is replaced by kakpipe <socket>
and this will
make subsequent $EDITOR
invocations just write the filename to the
socket. The running server will catch that filename and send an edit
command to an existing Kakoune instance.
kakpipe
The first argument is the path to a socket and all the remaining arguments form a string that is written to the socket.
kakwrap
Start a new Kakoune client inside an existing session that is unique for each directory. If the session does not exist yet, start it too.
Recommended tweaks
- Make Broot open all files in
$EDITOR
. - Tweak Kakoune runtime to forward
kak_client
andkak_session
to the windowing system. This makes:terminal kakedit
become the fun bit.
See also
The infamous connect.kak is much better in (almost) every aspect. It's too big for my use cases and I prefer a single binary over a collection of runtime scripts.