Skip to content

iago-lito/intim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intim

interactively interface vim with interpreters


This plugin makes you open, from within Vim, an interactive interpreter in another terminal. This interpreter may be a shell, python, R or anything you want. You feed input to this terminal via predefined or custom Vim mappings: like sending commands, interrupting, restarting, analyzing variables etc.

This plugin is mostly inspired from vim-R plugin, a great plugin dedicated do this with R.
The intent is to extend the idea to any interpreter and to offer more configuration options.

Major features, as for today:

  • Launch interpreter session without leaving Vim.
  • Send lines, words, visual selections, chunks and whole files to your interpreter.
  • Dynamically update your syntax file to get your script variables colored as they get declared in your interpreter.
  • Use custom hotkeys to send very specific expressions built from the variables currently under cursor.
  • Bonus hotkeys edit your very script with these specific expressions.
  • Access and read the interpreter help from within a vim buffer.
  • Detect and handle debug modes.
  • Enter loops to get into their execution contexts.
  • Quit and restart Vim without exiting the session.
  • Easy configuration.
  • Easy extension to other languages.
    • Full-support yet for:
      • python, (Pdb) (2, 3, ipython, bpython, ...)
      • R
    • A few utilities already implemented for:
      • bash
      • LaTeX
      • Rust, C++ (gdb)

Installation

Intim uses tmux to open a multiplexed interactive shell session. Then Intim uses it to launch and communicate with your favourite interpreter. Tmux is typically installed on debian-based systems with:

sudo apt-get install tmux

on Arch, try:

sudo pacman -S tmux

Once done, install Intim with any Vim package manager you like.

Typically

cd ~/.vim/bundle
git clone https://github.com/iago-lito/intim

With Vundle

Add the following line to your .vimrc:

Plugin 'iago-lito/intim'

Then run :PluginInstall.

First steps

Launch and close an Intim session with these default mappings.

nmap <F10> <Plug>IntimLaunchSession
nmap <F2>  <Plug>IntimEndSession  

They should be automatically defined by Intim, unless you wish changing them to something you like better. Intim will try never to override a mapping you had before. In this case, you will have to pick another mapping yourself.

Then, start communicating with your interpreter with these default mappings:

  • <space>: send the current line to your interpreter.
  • ,<space>: send the word under cursor.
  • ,uc: update syntax coloring as your variables and functions get declared.
  • ,mx-hotkey: ask python for the max() of the variable under cursor.
    • ;mx-edition-hotkey: actually wrap your variable in max().
  • ,sm-hotkey: ask R for the summary() of the variable under cursor.
    • ;sm-edition-hotkey: actually wrap your variable in summary().
  • <F1>: ask your interpreter for help about the item under cursor.

Configure

Remap anything you want.

Enjoy hooks to manipulate, tile, bring focus to your terminal, play sounds or anything you like, for instance:

call IntimLaunchCommand('python', ['cd ~'])     " first commands to tmux
call IntimInvokeCommand('python', 'python3 -B') " invoke your interpreter the way you like

Create any new hotkey you like, for instance:

call Intim_prefixedExpression('python', 'sf', 'self = ')
call Intim_headedExpression('R', 'ac', 'as.character')
call Intim_hotkeys('R', 'ii', '* <- * + 1')

Find more in :help intim<cr>.

Contribute

Intim code is open. It comes with no guarantees. But it also comes with extension points, and complete documentation to encourage development of any new feature. Feel free to contribute of course: share, comment, report bugs, ask for features, help in development, anything's good :)

License

This package is licensed under the GPL v3 license. © 2020 Intim contributors