Motivation
For almost a year now, I am an avid user of the “post-modern text editor” Helix, which replaced NeoVim for me entirely. In Helix I write all kinds of configs, texts and code, primarily in R. Helix works flawlessly with it, especially with the built-in LSP. The only gripe I had with this was, that there was no easy way to write R-code in Helix and send it directly and interactively to R’s REPL, as you would in typical R IDEs like RStudio.
So earlier this year, I tried to workaround that issue by experimenting with
TMUX and its send-keys
feature. The
results of this are available as installable script(s)
in my git-repository.
Functionality
The idea behind it is quite simple: A TMUX session with a pre-defined name is
spawned that runs the REPL we want to send our code to. This could be R, Python,
Bash, … Next, Helix sends code in its selection to some process
via its pipe-to
command. This
process’ job is to send the highlighted text to tmux line-by-line.
In its simplest form, the REPL in tmux could be started as:
|
|
The process that send text to this tmux session, let’s call it send-to-tmux.sh
could be as easy as:
We could set up a keyboard shortcut for this in Helix in selection mode (hitting Ctrl-C twice):
Using helix-term
The final script(s) in my git-repository are slightly more complicated to allow a more streamlined workflow, such as sending the current code-paragraph in insert or normal mode from Helix and setting launching a separate tmux-session for each working-directory, so you can run multiple such processes at the same time.
In short, you can use my helix-term
setup by running helix-term /usr/bin/R
in the same working directory as the Helix process and hitting Ctrl-C
twice
for the code chunk you would like to send to the R
-process.
Noteworthy alternatives
In a conversation
with another Helix user,
we found that we might have different use-cases. This user came up with another,
yet similar approach that tries to turn Helix a little bit more into an IDE:
hide. If helix-editor
is too bare
bones for your use-case, maybe hide
is a better approach for you.