Tidal in the Kakoune editor

On the off chance that there’s someone else here who uses the same oddball editor as me, here’s how I got tidal working in kakoune:

Install repl-bridge

Add a file called tidal to it’s config (as described in repl-bridge’s readme) with this content:

bash -c "ghci -ghci-script $(ghc-pkg field -f ~/.cabal/store/ghc-$(ghc --numeric-version)/package.db tidal data-dir --simple-output)/BootTidal.hs"

Then in kakoune’s config bind some commands:

map global user <ret> 'Zx: repl-bridge tidal send<ret>z'
map global user a ': repl-bridge tidal send<ret>'

That gives you <user> enter that works like shift-enter in other editors (executes the current line) and <user> a that executes your current selection, which could get pretty crazy if you have multiple selections active. I’m sure there’s a way to send the current lexical block (like ctrl-enter in other editors) but I haven’t figured it out yet.

Generally this works pretty well. It has trouble shutting down the ghci process when you exit so sometimes you have to kill it yourself. And it doesn’t work from a kak client connected to a session, I’m not sure what’s going on there.


hey, I didn't see this, so I did something similar myself.

1 Like

Came here to post this. Tom, thanks a lot for creating this plugin
I've been struggling to do it myself for a while, so I can't wait to finally try it!

Hey, my first user, neat! :slight_smile:

I have to make a small change to save and restore the selection when sending data. appart from that, it I find it fairly usable - even though there is no intelligent completion and all that.

1 Like

Hey Tom, do you get tidal syntax to work properly on kakoune? I tried set buffer filetype haskell to no avail...
Also, as I call tidal-send-block, I think it triggers tmux's copy mode. What ends up happening is half the block gets erased, nothing is sent to tidal and I have to exit copy mode (C-Esc) in order to be able to use kak colon commands again. Not sure if that's intentional or some accidental override I made, but some help is appreciated :slight_smile:

hey ghales, I think I know the problem. kakoune's send-text command will work only if the repl pane was opened by kakoune (ang given a special name).

So, the procedure is the following:

  1. open tmux
  2. open your tidal file with kakoune
  3. start the repl with :tidal-start-repl

at this point, tidal-send-line and tidal-send-block should work as expected. Note this is still rather crude - for example sending a block will loose your current selection, which sucks. Also, I haven't converted the module to the new require-module format.

here is my kakrc, just in case.

require-module plug

plug plug https://github.com/alexherbo2/plug.kak

plug-old tidal https://github.com/tgirod/tidal.kak

hook global WinSetOption filetype=haskell %{
	map buffer user s ':tidal-send-block<ret>'
	map buffer user h ':tidal-hush<ret>'
1 Like

hey tom! thanks for the help. I'm still getting an error running :tidal-start-repl: 2:6: 'repl' wrong argument count.
Tried debugging it but my kak scripting skills are non-existing

hmm, weird.

you didn't forget to run kakoune in a tmux session? repl is actually an alias for either tmux-repl-horizontal when running in a tmux session, or x11-repl when not - and they don't take the same parameters, which sucks.

So, a few questions:

  • are you running inside tmux?
  • if you do, which version of kakoune?
  • when you type :repl, what does the help bubble say?

That's nuts. I'm running kak in a tmux session alright, but kak -version returns Kakoune unknown. typing repl triggers a bubble for "tmux-repl-horizontal".

I made a PR issuing a fix I tried: changing line 14 of tidal.kak to repl "ghci -ghci-script %opt{tidal_boot_file}".

I figured the color thing out. I was missing the set -g default-terminal "screen-256color" option in my tmux conf

what's your setup again? you seem to be jumping through hoops when it went pretty smoothly on my side...

anyway, I pushed a new version yesterday where I cleaned the code a bit. To simplify things, BootTidal.hs is now hardcoded, so you need to copy it in your working directory.