Skip to content

hasundue/vim-pluto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-pluto

A plugin for editing Pluto notebooks with Vim.

Currently, a couple of different versions of the plugin are being developed.

  • A minimalistic helper plugin to edit .jl notebook files, which is supposed to interact with Pluto indirectly (main branch)
  • A plugin which turns your Vim into a front-end of Pluto, interacting with Pluto directly (dev branch)

Requirements

Installation

  1. Install Deno (see https://deno.land/#installation)
  2. Install denops.vim and vim-pluto with your package manager

ex. vim-plug

Plug 'vim-denops/denops.vim'
Plug 'hasundue/vim-pluto'

Configuration

vim-pluto does not provide any default key mappings. You have to do it manually.

Example:

nnoremap <silent> <LocalLeader>O :call pluto#insert_cell_above()<CR>
nnoremap <silent> <LocalLeader>o :call pluto#insert_cell_below()<CR>

nnoremap <silent> <LocalLeader>yy :call pluto#yank_cell()<CR>
nnoremap <silent> <LocalLeader>dd :call pluto#delete_cell()<CR>

nnoremap <silent> <LocalLeader>P :call pluto#paste_cell_above()<CR>
nnoremap <silent> <LocalLeader>p :call pluto#paste_cell_below()<CR>

nnoremap <silent> <LocalLeader>t :call pluto#toggle_code()<CR>

Recommended Usage

Launch Pluto server with auto_reload_from_file = true.

Example:

import Pluto
Pluto.run(auto_reload_from_file = true)

Enable autoread function of Vim.

Example:

set autoread
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
autocmd FileChangedShellPost * echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None

Edit a notebook (.jl file) in Vim while opening the notebook in Pluto web UI.

Provided Functions

Insert a cell

  • pluto#insert_cell_above()
  • pluto#insert_cell_below()

Insert an empty cell above/below the cell under the cursor and start editing it.

Yank/cut/paste a cell

  • pluto#yank_cell()
  • pluto#delete_cell()

Yank/cut cell under the cursor and put it into the register reserved for the plugin.

  • pluto#paste_cell_above()
  • pluto#paste_cell_below()

Paste a cell in the register above/below the cell under the cursor.

Show/hide code

  • pluto#show_code()
  • pluto#hide_code()
  • pluto#toggle_code()

Change visibility of code in the cell under the cursor.

Changes are not reflected in Web UI until a reload of the notebook because Pluto lacks of the implementation, unfortunately.