GithubHelp home page GithubHelp logo

optionalg / vim-slime Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jpalardy/vim-slime

0.0 3.0 0.0 372 KB

A vim plugin to give you some slime. (Emacs)

Home Page: http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/

License: MIT License

Vim Script 100.00%

vim-slime's Introduction

vim-slime

Demo

vim-slime session with R

What is Vim-Slime?

Context for SLIME:

SLIME is an Emacs plugin to turn Emacs into a Lisp IDE. You can type text
in a file, send it to a live REPL, and avoid having to reload all your code
every time you make a change.

Vim-slime is a humble attempt at getting _some_ of these features into Vim.
It works with any REPL and isn't tied to Lisp.

Grab some text and send it to a GNU Screen / tmux / whimrepl / ConEmu session / NeoVim Terminal / Vim Terminal

VIM ---(text)---> screen / tmux / whimrepl / ConEmu / NeoVim Terminal / Vim Terminal

Presumably, your session contains a REPL, maybe Clojure, R or python. If you can type text into it, vim-slime can send text to it.

The reason you're doing this? Because you want the benefits of a REPL and the benefits of using Vim (familiar environment, syntax highlighting, persistence ...).

More details in the blog post.

Installation

I recommend installing pathogen.vim, and then simply copy and paste:

cd ~/.vim/bundle
git clone git://github.com/jpalardy/vim-slime.git

If you like it the hard way, copy plugin/slime.vim from this repo into ~/.vim/plugin.

Usage

Put your cursor over the text you want to send and type:

C-c, C-c       --- the same as slime

You can just hold Ctrl and double-tap c.

The current paragraph, what would be selected if you typed vip, is automatically selected. To control exactly what is sent, you can manually select text before calling vim-slime.

Vim-slime needs to know where to send your text, it will prompt you. Vim-slime will remember your answers and won't prompt you again. But if you need to reconfigure, type:

C-c, v         --- mnemonic: "variables"

or call:

:SlimeConfig

Configuration

GNU Screen

By default, GNU Screen is assumed, you don't have to do anything. If you want to be explicit, you can add this line to your .vimrc:

let g:slime_target = "screen"

Because Screen doesn't accept input from STDIN, a file is used to pipe data between Vim and Screen. By default this file is set to $HOME/.slime_paste. The name of the file used can be configured through a variable:

let g:slime_paste_file = "$HOME/.slime_paste"
" or maybe...
let g:slime_paste_file = tempname()

WARNING: This file is not erased by the plugin and will always contain the last thing you sent over.

When you invoke vim-slime for the first time, you will be prompted for more configuration.

screen session name:

This is what you put in the -S flag, or one of the line from "screen -ls".

screen window name:

This is the window number or name, zero-based.

tmux

Tmux is not the default, to use it you will have to add this line to your .vimrc:

let g:slime_target = "tmux"

Before tmux 2.2, tmux accepted input from STDIN. This doesn't work anymore. To make it work out without explicit config, the default was changed to use a file like screen. By default this file is set to $HOME/.slime_paste. The name of the file used can be configured through a variable:

let g:slime_paste_file = "$HOME/.slime_paste"
" or maybe...
let g:slime_paste_file = tempname()

WARNING: This file is not erased by the plugin and will always contain the last thing you sent over.

When you invoke vim-slime for the first time, you will be prompted for more configuration.

tmux socket name or absolute path:

If you started tmux with the -L or -S flag, use that same socket name or path here.
If you didn't put anything, the default name is "default".

tmux target pane:

Note that all of these ordinals are 0-indexed by default.

":"     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
"%i"    means i refers the pane's unique id

You can configure the defaults for these options. If you generally run vim in a split tmux window with a REPL in the other pane:

let g:slime_default_config = {"socket_name": split($TMUX, ",")[0], "target_pane": ":.2"}

whimrepl

whimrepl is not the default, to use it you will have to add this line to your .vimrc:

let g:slime_target = "whimrepl"

When you invoke vim-slime for the first time, you will be prompted for more configuration.

whimrepl server name

This is the name of the whimrepl server that you wish to target.  whimrepl
displays that name in its banner every time you start up an instance of
whimrepl.

ConEmu

ConEmu is not the default, to use it you will have to add this line to your .vimrc:

let g:slime_target = "conemu"

When you invoke vim-slime for the first time, you will be prompted for more configuration.

ConEmu console server HWND

This is what you put in the -GuiMacro flag. It will be "0" if you didn't put
anything, adressing the active tab/split of the first found ConEmu window.

By default the windows clipboard is used to pass the text to ConEmu. If you experience issues with this, make sure the conemuc executable is in your path.

Vim :terminal

Vim :terminal is not the default, to use it you will have to add this line to your .vimrc:

let g:slime_target = "vimterminal"

When you invoke vim-slime for the first time, you will be prompted for more configuration.

Vim terminal configuration can be set by using the following in your .vimrc:

let g:slime_vimterminal_config = {options}

for possible options, see :help term_start()

NeoVim terminal

NeoVim :terminal is not the default, to use it you will have to add this line to your .vimrc:

let g:slime_target = "neovim"

When you invoke vim-slime for the first time, you will be prompted for more configuration.

Advanced Configuration

If you need this, you might as well refer to the code :-)

If you don't want the default key mappings, set:

let g:slime_no_mappings = 1

The default mappings are:

xmap <c-c><c-c> <Plug>SlimeRegionSend
nmap <c-c><c-c> <Plug>SlimeParagraphSend
nmap <c-c>v     <Plug>SlimeConfig

If you want vim-slime to prefill the prompt answers, you can set a default configuration:

" screen:
let g:slime_default_config = {"sessionname": "xxx", "windowname": "0"}

" tmux:
let g:slime_default_config = {"socket_name": "default", "target_pane": "1"}

If you want vim-slime to bypass the prompt and use the specified default configuration options, set the g:slime_dont_ask_default option:

let g:slime_dont_ask_default = 1

By default, vim-slime will try to restore your cursor position after it runs. If you don't want that behavior, unset the g:slime_preserve_curpos option:

let g:slime_preserve_curpos = 0

Language Support

Vim-slime might have to modify its behavior according to the language or REPL you want to use.

Many languages are supported without modifications, while others might tweak the text without explicit configuration:

  • coffee-script
  • fsharp
  • haskell / lhaskell -- README
  • ocaml
  • python / ipython -- README
  • scala
  • sml

vim-slime's People

Contributors

jpalardy avatar romeovs avatar peterrincker avatar selliera avatar caio avatar dbeecham avatar 0 avatar katusk avatar rgrinberg avatar thejohnfreeman avatar addadi avatar jrpotter avatar ethagnawl avatar rwstauner avatar oracal avatar sindex avatar kindlychung avatar lingnand avatar lpil avatar maxst avatar novadev94 avatar tmhedberg avatar andars avatar jdiez17 avatar sursh avatar gpelouze avatar sirspoony avatar munshkr avatar dariusf avatar esamattis avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.