Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lukoshkin/slime-wrapper.nvim

Jupyter cell layout in Neovim
https://github.com/lukoshkin/slime-wrapper.nvim

neovim-lua-plugin vim-ipython vim-slime

Last synced: about 1 month ago
JSON representation

Jupyter cell layout in Neovim

Awesome Lists containing this project

README

        

# Slime-Wrapper to Mimic Jupyter in Vim

This project is wrapper around the two plugins:
* [vim-slime](https://github.com/jpalardy/vim-slime)
* [vim-ipython-cell](https://github.com/hanschen/vim-ipython-cell)

The new functionality that the wrapper enables is an easier launching and
terminating process of an IPython session, subjectively better mappings, and
some bug fixes, that further might be incorporated in [vim-ipython-cell](
https://github.com/hanschen/vim-ipython-cell). However, the better decision is
to re-write the latter in Lua or at least VimL (see
[problems](#problems-with-dependencies)).

## Installation

With [**Packer**](https://github.com/wbthomason/packer.nvim)

```lua
use {
'rxi/json.lua',
run = 'mkdir -p lua/json && mv json.lua lua/json/init.lua',
}

use {
'lukoshkin/slime-wrapper.nvim',
requires = {
'jpalardy/vim-slime',
'hanschen/vim-ipython-cell',
'lukoshkin/bterm.nvim',
'lukoshkin/auenv.nvim',
},
config = function ()
require'auenv'.setup()
require'bottom-term'.setup()

--- Installing with defaults
-- require'slime-wrapper'.setup()

--- Your custom configuration
require'slime-wrapper'.setup {
keys = {
select_session = 'ss',
ipython_session = 'ip',
},
--- Cell delimiter
colors = {
bold=true,
bg='#444d56',
fg='#b2b2b2'
},
}
end
}
```

For better customization and understanding of the underlying dependencies,
visit [bterm.nvim](https://github.com/lukoshkin/bterm.nvim) and
[auenv.nvim](https://github.com/lukoshkin/auenv.nvim) sites.

## Mappings

Valid only for Python files.

`` - execute a cell.
`` - execute a cell (verbose: using `%cpaste`).
`` - execute a cell and jump to the next cell.

`n` - jump to the next cell.
`p` - jump to the previous cell.
`x` - close all plots (send `plt.close('all')`).
`l` - clear IPython screen.
`00` - restart IPython session.

`:Run` - run the whole script.
`:RunTime` - run the whole script and measure the execution time.
`:Clear` - clear IPython screen.

---

**Select slime session**  ─  `ss`  _(works for any
filetype)_
**Start IPython session**  ─  `ip`

**Cell delimiters:**
`# %%`,  `#%%`,  `'# In [ ]`,  `# In []`
The first two delimiters are valid for any filetype.

---

_NOTE:_ one can map `` to `` :
`vim.g.maplocalleader = ''`

## Problems with Dependencies

* After wrapping with `slime-wrapper.nvim`, the chain of function calls looks
like this:

**Lua** (slime-wrapper) **→ Python** (vim-ipython-cell) **→ VimL → C**

If not building on top of existing plugins but writing from scratch, it is
possible to reduce the number of elements in the chain to **2**. Currently,
it is not a goal, just a remark.

* `IPythonCell...` commands are available for any filetype. Not just Python ft.