Skip to content

sinetoami/vim-rbrun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

vim-rbrun

A simple plugin to make run Ruby code on Vim. Inspired by vim-ruby-run.

Features

  • Run only ruby code. So, the default keymap is freely available to another use by another buffers with another filetypes
  • This plugin run script in four different ways:
    • Run full ruby script of the current file
    • Run just the one line under the cursor
    • Run piece of a selected code block
    • Paste the output on current file:
      • Just one line under the cursor
      • Or piece of a selected code block
    • Integration with vimux
      • This feature requires to install vimux

Work in progress (see TODO).

Instalation

Use your favorite plugin manager, or try dein.vim.

With dein.vim

Install dein.vim, and add the following line to your ~/.vimrc:

call dein#add('sinetoami/vim-rbrun')

And then execute the following command on to your Vim:

:call dein#install()

Manually

If you are not using a package manager, download manually the zip repo and extract the files to ~/.vim:

$ cp vim-rbrun-master.zip ~/.vim
$ cd ~/.vim
$ unzip vim-rbrun-master.zip -d /destination/plugins/folder
$ rm vim-rbrun-master.zip

Documentation

This section will contain a brief documentation.

Configuration

g:rbrun_strategy

let g:rbrun_strategy = "vimux"

There are two defined values for this variable: vimux and basic. The vimux value will force the command to run on a tmux pane using VimuxRunCommand function provided by the vimux plugin. The basic is enabled by default and run the command with :! on Neovim.

g:rbrun_enable_mappings

let g:rbrun_enable_mappings = 0

When this variable is set with 0, disable default mappings (enabled by default with: 1).

g:rbrun_maps

let g:rbrun_maps = { 'RunScript': '<A-e>' }

This variable receive a dictionary in a form of {'rbrun-command-aliases': 'map'}.

  • rbrun-command-aliases will receive one of a rbrun default command aliases
  • map will receive a map that you want

By default, vim-rbrun define the following command aliases with one respective default map:

let g:rbrun_maps = {
  \'RunScript': '<A-e>',
  \'RunLine': '<C-x>',
  \'RunCodeBlock': '<C-x>',
  \'PasteOutputLine': '<C-A-x>',
  \'PasteOutputBlock': '<C-A-x>'
}

If you want to change one of these maps, do something such the following line:

let g:rbrun_maps = { 'PasteOutputLine': '<leader>rbl' }

Set this will just change the map that corresponds with PasteOutputLine aliases. This will paste the output of the line under the cursor using <leader>rbl shortcut.

Default Commands

  • <Plug>RbRunScript will run the current file
  • <Plug>RbRunLine will run the line under the cursor
  • <Plug>RbRunPasteOutputLine will paste output of the line under the cursor
  • <Plug>RbRunCodeBlock will run a piece of selected code block
  • <Plug>RbRunPasteOutputBlock will paste output of the selected code block

TODO

  • Do paste output of all current script

Self-Promotion

Do you like this plugin? Come on:

  • Star and follow the repository on GitHub.
  • Follow me on

License

MIT License

About

Vim Plugin: Simple plugin to execute ruby code on Vim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published