Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lukoshkin/bterm-repl.nvim
Switch from Jupyter Notebooks with vim-editing extensions to a pure way of development in Neovim. Bterm-repl allows you to execute commands and cells of code in an interpreter window
https://github.com/lukoshkin/bterm-repl.nvim
ipython neovim-lua-plugin repl vim-ipython
Last synced: 24 days ago
JSON representation
Switch from Jupyter Notebooks with vim-editing extensions to a pure way of development in Neovim. Bterm-repl allows you to execute commands and cells of code in an interpreter window
- Host: GitHub
- URL: https://github.com/lukoshkin/bterm-repl.nvim
- Owner: lukoshkin
- License: mit
- Created: 2023-10-04T16:03:18.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-27T21:29:38.000Z (5 months ago)
- Last Synced: 2024-09-29T18:23:39.242Z (about 1 month ago)
- Topics: ipython, neovim-lua-plugin, repl, vim-ipython
- Language: Lua
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# REPL-like Extension for [Bterm](https://github.com/lukoshkin/bterm.nvim)
`bterm` plugin gives a quicker access to a terminal in Neovim.
However, it does not allow sending lines of code to an interpreter open
in `BottomTerm` instance. This REPL-like extension aims to bridge this gap.## Features
- Written in pure Lua
(Ok, Neovim + Lua 🙃)- Easy access to interpreter windows.
Open IPython, bash/zsh, or lua in a `BottomTerm` instance with just a keymap.- Send code to execute it in an interpreter window.
Currently, execution in cells are available for `'python'`, `'sh'`,
and `'lua'` buffers.
Line execution works for all buffers.- Split code into sections with cell separators.
By default, they are `--#` and `#%%` for `'lua'` and `'python'` and `'sh'`
buffers, respectively.
Quick navigation is possible using key mappings.- Set the line separator to alter the way how copied lines are concatenated.
Swiftly switch between '\n' and your custom separators.- Highlight cell separators with customizable colors.
One can specify color per `filetype`.- Unlike "[vim-ipython](https://github.com/hanschen/vim-ipython-cell)
\+ [vim-slime](https://github.com/jpalardy/vim-slime)" plugins combo,
`bterm-repl` preserves
the content of the clipboard when sending code
for the execution. Moreover, you
can send code from host to a docker
container by properly choosing the line separator.## Installation
With [**packer**](https://github.com/wbthomason/packer.nvim)
```lua
use {
'lukoshkin/bterm-repl.nvim',
requires = 'lukoshkin/bterm.nvim',
config = function ()
require'bottom-term'.setup()
require'bottom-term-repl'.setup()
end
}
```## Mappings
_Standard mappings provided by the [bterm](https://github.com/lukoshkin/bterm.nvim) plugin:_
- `` ─ toggle a terminal window  _(_`BottomTerm` _instance)._
- `` ─ reverse the terminal orientation.
- `` ─ terminate the terminal session.
- `:BottomTerm ` ─ execute a `` in the terminal._Mappings available with the extension:_
- `l` ─ clear the interpreter screen
- `jn` ─ jump to the next cell
- `jp` ─ jump to the previous cell
- `00` ─ restart the interpreter session
- `x` ─ close all pyplot figures
- `` ─ execute the current line in the interpreter window
- `` ─ execute a cell in the interpreter window
- `` ─ execute a cell and jump to the next one
- `s` ─ toggle line separator to its second set value
- `ss` ─ select interpreter for a new session
- `ip` ─ launch IPython in the interpreter window## Customization
One can adjust to their needs by altering some of the defaults below.
```lua
use {
'lukoshkin/bterm-repl.nvim',
requires = 'lukoshkin/bterm.nvim',
config = function ()
require'bottom-term-repl'.setup {
clipboard_occupation_time = 500,
line_separators = { nil, '; \\\n', '; ', '' },
cell_delimiters = {
python = { '#%%', '# %%', '# In\\[\\(\\d\\+\\| \\)\\]:' },
lua = { '--#' },
sh = { '#%%' },
},
keys = {
clear = 'l',
next_cell = 'jn',
prev_cell = 'jp',
restart = '00',
close_xwins = 'x',
run_line = '',
run_cell = '',
run_and_jump = '',
toggle_separator = 's',
toggle_separator_backward = 'S',
select_session = 'ss',
ipy_launch = 'ip',
},
colors = {
python = { bold = true, bg = '#306998', fg = '#FFD43B' },
lua = { bold = true, bg = '#C5C5E1', fg = '#6B6BB3' },
sh = { bold = true, bg = '#293137', fg = '#4EAA25' },
}
}
end
}
````clipboard_occupation_time` - time after which the content of the clipboard
will be restored. If it is too short, the restored content will be sent to
IPython instead. Note that it is only valid for IPython and when the line
separator is set to `nil` (what is equivalent to `'\n'` in terms of the
implementation).`gain_focus_time`: some commands (like `clear`) may require round trips to the
terminal window with a short switch to insert mode to gain focus at the current
log stream. Too short values of the option may be not enough to scroll down the
screen.## Further Development
- [x] Add base functionality.
- [ ] Add more options for finer configuration.
- [x] Add line separator toggle (whether to join lines with '\n' or ';').
- [ ] Add demos: working in IPython; different filetypes; highlighting;
toggling the separator.