Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

SLIME inspired tmux integration plugin for Vim

branch: master

Revert "2013!"

This reverts commit de8057e.

It appears this was not needed .
latest commit 19af0286a1
Esa-Matti Suuronen authored September 05, 2013
Octocat-spinner-32 ftplugin Scheme: add support for normal SlimuxSendXXX function September 05, 2013
Octocat-spinner-32 plugin Fix: Fail to send text that is too long. September 05, 2013
Octocat-spinner-32 LICENSE Revert "2013!" September 05, 2013
Octocat-spinner-32 README.md Do not enable scheme keybindings by default #20 September 05, 2013
README.md

Slimux

This is a SLIME inspired tmux integration plugin for Vim. It makes it easy to interact with different tmux panes directly from Vim. It has two styles for interacting with panes. REPL and Shell styles.

REPL commands are designed to work with various Read Eval Print Loops such as python, irb (Ruby), node (Javascript), coffee (CoffeeScript) etc. This is loosely modelled after SLIME for Emacs. Shell commands are designed to work with normal shells such as bash. These are useful for running tests for example.

Main difference between these is pane configuration visibility. Each buffer has own configuration for REPL, but for Shell there is only one global configuration. The configuration is prompted from user when the commands are used for the first time. The configuration happens interactively. You will see list of available tmux panes and you can choose one by hitting enter on top of one.

Also REPL commands can have custom pre, post and escape hooks. These allows interaction with some more complex REPLs such as the CoffeeScript REPL.

This plugin borrows ideas and some code from vim-slime.

Blog post

http://esa-matti.suuronen.org/blog/2012/04/19/slimux-tmux-plugin-for-vim/

Ascii.io screencast

http://ascii.io/a/409

Installation

Use pathogen and put files to $HOME/.vim/bundle/slimux/

Slimux requires fairly recent tmux version. Be sure you have 1.5.x or later.

REPL Commands

SlimuxREPLSendLine

Send current line to configured pane.

SlimuxREPLSendSelection

Send last visually selected text to configured pane.

SlimuxREPLConfigure

Prompt pane configuration for current buffer.

Shell Commands

SlimuxShellPrompt

Prompt for a shell command and send it to configured tmux pane.

SlimuxShellLast

Rerun last shell command(prompts for a shell command if none was run before).

SlimuxShellRun

Specify a shell command to run directly, without the prompt:

:SlimuxShellRun rspec spec/foo_spec.rb

Suitable for mapping and other automation.

Note that you need to double any escapes intended for the shell using this command. E.g. to list files with actual asterisks in their name:

:SlimuxShellRun ls \\*

SlimuxShellConfigure

Prompt global pane configuration for the shell commands.

Sending Keys

SlimuxSendKeysPrompt

Prompt for a key sequence using the 'tmux send-keys' syntax and send it to a configured tmux pane. E.g. Lets say you want to stop the webserver currently running in a shell(ctrl+c) and restart it(assuming the command to start is 'make run-server'):

:SlimuxSendKeysPrompt
KEYS>C-C 'make run-server' Enter

or run previous command with

KEYS>Up Enter

In short, some strings such as 'C-C' or 'Enter' have special meanings, while others are sent as a sequence of character keys(in the above example, 'make run-server')

SlimuxSendKeysLast

Resends the last key sequence sent(prompts for a sequence if none was sent before).

SlimuxSendKeysConfigure

Prompt global pane configuration to send the key sequence.

Keyboard Shortcuts

Slimux does not force any shortcuts on your Vim, but here's something you can put to your .vimrc

map <Leader>s :SlimuxREPLSendLine<CR>
vmap <Leader>s :SlimuxREPLSendSelection<CR>
map <Leader>a :SlimuxShellLast<CR>
map <Leader>k :SlimuxSendKeysLast<CR>

Or if you like something more Emacs Slime style try something like this:

map <C-c><C-c> :SlimuxREPLSendLine<CR>
vmap <C-c><C-c> :SlimuxREPLSendSelection<CR>

You may also add shortcuts to other commands too.

For Scheme Slimux has few extra bindings. Enable them with

let g:slimux_scheme_keybindings=1

For more information refer to the scheme plugin header.

Adding support for new languages

Usually new there is no need to do anything. For example Ruby and Node.js REPLs works just fine out of box, but for some languages you have to do some preprocessing before the code can be sent. There are three hooks you can specify for each language.

Custom escaping function

function SlimuxEscape_<filetype>(text)
    return a:text
endfunction

Pre send hook

function SlimuxPre_<filetype>(target_pane)
endfunction

Post send hook

function SlimuxPost_<filetype>(target_pane)
endfunction

Just add these to ftplugin directory contained within this plugin (and sent a pull request on Github!). You can use Python and CoffeeScript hooks as examples.

Other Vim Slime plugins

Before I created this plugin I tried several others, but non of them satisfied me. They where too complicated or just didn't support the languages I needed. So if Slimux isn't your cup of tea, maybe one of these is:

Something went wrong with that request. Please try again.