# Tidal in the Kakoune editor

**URL:** <https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391>\
**Category:** Uncategorized\
**Created:** [12 April 2020 18:02 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391 "2020-04-12T18:02:44Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![alec](https://uzu.lurk.org/user_avatar/uzu.lurk.org/alec/32/305_2.png) [@alec](https://uzu.lurk.org/u/alec)\
**Post date:** [12 April 2020 18:02 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391/1 "2020-04-12T18:02:45Z")

</div>

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](https://github.com/JJK96/kakoune-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"
tidal> 
tidal| 

```

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.

---

<div class="post-metadata">

**Author:** ![tgirod](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@tgirod](https://uzu.lurk.org/u/tgirod)\
**Post date:** [29 September 2020 12:52 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391/2 "2020-09-29T12:52:55Z")

</div>

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

> **[GitHub - tgirod/tidal.kak: Using the Tidal Cycles live programming...](https://github.com/tgirod/tidal.kak)**
>
> Using the Tidal Cycles live programming environment from kakoune - GitHub - tgirod/tidal.kak: Using the Tidal Cycles live programming environment from kakoune

---

<div class="post-metadata">

**Author:** ![ghales](https://uzu.lurk.org/user_avatar/uzu.lurk.org/ghales/32/2171_2.png) [@ghales](https://uzu.lurk.org/u/ghales)\
**Post date:** [1 October 2020 11:24 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391/3 "2020-10-01T11:24:05Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![tgirod](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@tgirod](https://uzu.lurk.org/u/tgirod)\
**Post date:** [1 October 2020 11:50 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391/4 "2020-10-01T11:50:58Z")

</div>

Hey, my first user, neat! 🙂

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.

---

<div class="post-metadata">

**Author:** ![ghales](https://uzu.lurk.org/user_avatar/uzu.lurk.org/ghales/32/2171_2.png) [@ghales](https://uzu.lurk.org/u/ghales)\
**Post date:** [25 November 2020 03:41 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391/5 "2020-11-25T03:41:37Z")

</div>

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](https://www.rockyourcode.com/copy-and-paste-in-tmux/). 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 🙂

---

<div class="post-metadata">

**Author:** ![tgirod](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@tgirod](https://uzu.lurk.org/u/tgirod)\
**Post date:** [25 November 2020 08:15 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391/6 "2020-11-25T08:15:14Z")

</div>

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.

```haskell
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 %{
    expandtab
	map buffer user s ':tidal-send-block<ret>'
	map buffer user h ':tidal-hush<ret>'
}

```

---

<div class="post-metadata">

**Author:** ![ghales](https://uzu.lurk.org/user_avatar/uzu.lurk.org/ghales/32/2171_2.png) [@ghales](https://uzu.lurk.org/u/ghales)\
**Post date:** [25 November 2020 12:03 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391/7 "2020-11-25T12:03:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tgirod](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@tgirod](https://uzu.lurk.org/u/tgirod)\
**Post date:** [25 November 2020 17:30 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391/8 "2020-11-25T17:30:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ghales](https://uzu.lurk.org/user_avatar/uzu.lurk.org/ghales/32/2171_2.png) [@ghales](https://uzu.lurk.org/u/ghales)\
**Post date:** [25 November 2020 18:00 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391/9 "2020-11-25T18:00:49Z")

</div>

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](https://github.com/tgirod/tidal.kak/pull/1) issuing a fix I tried: changing line 14 of tidal.kak to `repl "ghci -ghci-script %opt{tidal_boot_file}"`.

---

<div class="post-metadata">

**Author:** ![ghales](https://uzu.lurk.org/user_avatar/uzu.lurk.org/ghales/32/2171_2.png) [@ghales](https://uzu.lurk.org/u/ghales)\
**Post date:** [26 November 2020 02:19 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391/10 "2020-11-26T02:19:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tgirod](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@tgirod](https://uzu.lurk.org/u/tgirod)\
**Post date:** [26 November 2020 07:31 UTC](https://uzu.lurk.org/t/tidal-in-the-kakoune-editor/391/11 "2020-11-26T07:31:18Z")

</div>

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.
