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

https://github.com/lfrati/szent.nvim

A small plugin to send code from neovim to tmux using visual, paragraphs or cells.
https://github.com/lfrati/szent.nvim

ipython lua neovim-plugin slime

Last synced: about 1 month ago
JSON representation

A small plugin to send code from neovim to tmux using visual, paragraphs or cells.

Awesome Lists containing this project

README

          


szent_round_400

/sɛnt/ : holy [hu], past of send [en]


# szent.nvim
text
A tiny Neovim bridge that sends code from your current buffer to a tmux REPL using safe bracketed paste.

szent_example

## Features
- Target any tmux pane and paste via `load-buffer`/`paste-buffer -p`.
- Send from visual selection, paragraph or cell.
- Highlights the szent code (shoutout `vim.hl.range` for including a timeout)
- Checks that the target pane runs a known REPL command before sending.

## Requirements
- Neovim 0.10 or newer.
- A running tmux session with bracketed paste enabled.

## Installation
Using [lazy.nvim](https://github.com/folke/lazy.nvim):

```lua
{
"lfrati/szent.nvim",
config = function()
local szent = require("szent")

szent.setup {
repl_commands = { "python", "ipython", "uv" },
}
-- keybindings are not set by default ♻️
vim.keymap.set("x", "p", "(SzentVisual)")
vim.keymap.set("n", "p", "(SzentParagraph)")
vim.keymap.set("n", "r", "(SzentCellAndMove)")

end
}
```

## Usage
- `:SzentConfig` prompts for a tmux pane to send text to (in case you changed your mind about `:.2`).
image

- `send_visual()`, try to guess.
- `send_paragraph()`, another cryptic one.
- `send_cell({move = true})` sends the current delimited cell (defaults to `# %%`), and then moves the cursor to the next cell.
- `send_cell({move = false})` sends the current delimited cell (defaults to `# %%`), and then... nothing.

| Szent succesfully | Error while szending |
| ------------- | ------------- |
| success | error |
| Code sent succesfully is highlighted with `Visual` |

 `Target tmux pane :.2 is running 'zsh'.` 
  `Expected one of: python, ipython`
|

Tip: use text objects for the cell content:
```lua
vim.keymap.set({"o","x"}, "ic", ":lua require('szent').select_cell_inner()", { silent = true, desc = "inside cell" })
vim.keymap.set({"o","x"}, "ac", ":lua require('szent').select_cell_around()", { silent = true, desc = "around cell" })
```

## Configuration
All options are optional (duh.) and are merged with the defaults below:

```lua
require("szent").setup({
target_pane = ":.2", -- tmux pane target default (session:window.pane)
cell_delimiter = [[^\s*#\s*%%]], -- pattern that marks cell boundaries
repl_commands = {}, -- optional commands to assert before sending
timeout = 200, -- highlight timeout in milliseconds
})
```

Customize the popup picker colors with the exposed namespace:
```
'SzentCmd' : color pane command
'SzentActive' : color for the * marking the active pane
'FloatBorder' : color for the popup border
'FloatTitle' : color for the popup title
'Normal' : base text color in the popup
```
defining your own colors as follows:
```lua
local ns = require("szent").ui_namespace()
vim.api.nvim_set_hl(ns.popup, "FloatBorder", { fg = "#00ff00" })
```

## Thanks
- [slime](https://slime.common-lisp.dev/)
- [vim-slime](https://github.com/jpalardy/vim-slime)