A Vim plugin for Tidal.
Uses tmux and it is based on vim-slime for communication with Tidal (ghci).
You can start livecoding with Vim simply by running:
$ tidalvim
This creates a tmux session with Vim, Tidal and Dirt running on different panes.
Then, use one of these key bindings to send lines to Tidal:
<localleader>ss
: Send current inner paragraph (equivalent to doingvip
).<localleader>s
: Send current line or current visually selected block.
There are other bindings to control Tidal like:
<localleader>s[N]
: Send first ocurrence of stream number[N]
from the current cursor position.<localleader>[N]
: Silences stream number[N]
by sendingd[N] silence
.<localleader>h
: Silences all streams by sendinghush
.
The <leader>
key is a special key used to perform commands with a sequence of
keys. The <localleader>
key behaves as the <leader>
key, but is local to
a buffer. In particular, the above bindings only work in buffers with the
"tidal" file type set, e.g. files whose file type is .tidal
By default, there is no <localheader>
set. To define one, e.g. for use with
a comma (,
), write this on your .vimrc
file:
let maplocalleader=","
Reload your configuration (or restart Vim), and after typing ,ss
on a few
lines of code, you should see those being copied onto the Tidal interpreter on
the upper-right pane.
tmux is used to communicate between Vim and Tidal.
You can install it from the main repos:
$ sudo apt-get install tmux
$ brew install tmux
There seems to be a Cygwin package for tmux, but I haven't tested this plugin on Windows anyway, so you are on your own here.
If you happen to make it work, let me know so I can update this text!
A Vim plugins manager like Vundle or Pathogen is highly recommended. Install one of those if you don't have one. Check those links for instructions.
For example, using Vundle:
- Edit your
.vimrc
file and add these lines:
Plugin 'munshkr/vim-tidal'
- Restart Vim and execute
:PluginInstall
to automatically download and install the plugins.
Finally, go to the plugin repository and run make
to install the tidalvim
script.
$ cd ~/.vim/bundle/vim-tidal
$ sudo make install
By default, there are two normal keybindings and one for visual blocks using
your <localleader>
key. If you don't have one defined, set it on your
.vimrc
script with let maplocalleader=","
, for example.
You can configure tmux socket name and target pane by typing <localleader>c
.
About the target pane:
- ":" means current window, current pane (a reasonable default)
- ":i" means the ith window, current pane
- ":i.j" means the ith window, jth pane
- "h:i.j" means the tmux session where h is the session identifier (either session name or number), the ith window and the jth pane
TODO There are no options yet, but there are some variables inside tidalvim
that you can change:
DEFAULT_PATH=~
DEFAULT_FILE=foo.tidal
DIRT_PATH=~/dirt
DIRT_OPTIONS=
DEFAULT_PATH
is where Vim will start up.DEFAULT_FILE
is the file that will open first. The.tidal
extension is important (you can run:setfiletype haskell.tidal
in other case)DIRT_PATH
is where Dirt lies.DIRT_OPTIONS
are extra command-line options (like--channels
or--no-dirty-compressor
).
You can also edit BootTidal.hss
to run something else on init, like
connecting to a Dirt on a different
machine/host.