Announcement: repl.kak

repl.kak

I am super happy to announce my first public plugin, repl.kak

Your favorite language REPLs from kakoune.

thanks

As stated in the project README, it was heavily inspired by my time using conjure for neovim.
The kakoune-repl-bridge confirmed me that my FIFO based idea was possible (thanks @JJK96)
Thanks to the #kakoune IRC channel for the help !

explain

It allows you to launch, connect and send data to a REPL.
The REPL choice is based on the current buffer filetype or the first argument to repl-kak-init.
Multiple, same type, buffers use the same REPL, but individual instances can be generated using the second argument of repl-kak-init.

repl.kak simple showcase

For now, it only has integrations for :

  • ocaml
  • scheme (chicken)
  • python
  • sh
  • janet

But it is made so it’s super easy to add local custom integrations :blush:

next

I have some ideas on how to improve the plugin, but the v1 should already be usable.
The plugin comes with no default mapping, as suggested in the “Writing Plugins” section of the kakoune wiki, and no suggestions.
Since all functionalities are one command away, it should be easy to implement a custom user mode in one’s kakrc file.

contact

If you have any suggestions, want to propose an integration or an improvement, please feel free to contact me using the contributing section of the project’s README.
You also can contact me here or through my personal email thomas.teixeira at startmail dot com

5 Likes

This seems pretty cool!

Kakoune’s built-in REPL support is very reliable if you’re running inside tmux, or inside X11 and have the right tools installed, but people have found it difficult to use otherwise, so it’s nice to have some alternatives.

Is that what makes your plugin different - the fact that it works via FIFOs rather than a terminal, and comes with adapters to make different REPL tools work in that environment?

1 Like

I never thought about it that way.
I wanted to create a similar-ich experience to the conjure plugin. Kakoune’s built-in REPL has never occurred to me as a solution to this need (working with languages REPL from within my editor). Maybe because I do not use tmux or because it depends on xdotool, which I do not have installed on all my machines.

In the end, it was just a perfect excuse to make something from scratch, aahah.
The main goal really was to create something as minimal as possible, making use of as much “defaults” (pre-installed commands, POSIX syntax, etc…) as I could.

FIFOs are really nice to work with, and operate nicely with kakoune’s edit -fifo.
Using them allows one to always stay inside its editor; navigating REPLs output, sending new data, modifying the code, you can do it all from within kakoune, with your personal mappings.
This I found more comfortable.

Adapters are nice, and I like my solution to build them, but of the 5 built-in integrations (a.k.a. adapters) only one is really an improvement over using kakoune’s built-in REPL data-sending (and that’s not even entirely true, as some python REPL support file like indentation/spacing)

But yeah, the adapters are a cool part of the project!
Plus, the lookup code is local first, so you could write your owns, making ultra custom things with input/output :blush:

Another cool part, that is presented in the project’s README, but not here, is that you can have multiple same type buffer connected to the same REPL instance, sharing definitions across files. This is the default behavior right now, but one can always enforce a new instance when summoning a connection.

A small demo

Same filetype, multiple buffer - repl.kak - tchncs

1 Like