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

https://github.com/max607/nvim-terminal-send

A minimalist plugin to interact with CLIs of programming languages.
https://github.com/max607/nvim-terminal-send

ide neovim plugin

Last synced: 11 months ago
JSON representation

A minimalist plugin to interact with CLIs of programming languages.

Awesome Lists containing this project

README

          

# terminal-send

A minimalist plugin to interact with CLIs of programming languages like `R` and `Python`.

https://github.com/user-attachments/assets/bb844130-b303-466f-aad9-c373c9273c46

## Usage

This package aims to integrate with the usual vim workflow.
The basic setup is to open, e.g., an `R` script and a nvim terminal running `R` in split view.
Now you can send arbitrary text from the script to the terminal with `ts` and a *vim motion*.

Additional shortcuts are

* `tf` for focusing a terminal, e.g., if you use several `R` instances at once.
* `tr` for re-sending the last code selection.

## Installation

Install using your favorite package manager, e.g. [Lazy](https://github.com/folke/lazy.nvim):

```lua
require('lazy').setup({
'max607/nvim-terminal-send',
})
```

## Helpful shortcuts

Here are some some shortcuts I recommend for ease of use.

```lua
-- open splits on the right and below
vim.opt.splitright = true
vim.opt.splitbelow = true

-- alt + "vim direction" split navigation (normal mode)
vim.keymap.set('n', '', 'h', {noremap = true})
vim.keymap.set('n', '', 'j', {noremap = true})
vim.keymap.set('n', '', 'k', {noremap = true})
vim.keymap.set('n', '', 'l', {noremap = true})

-- alt + "vim direction" split navigation (insert and terminal mode)
vim.keymap.set({'i', 't'}, '', 'h', {noremap = true})
vim.keymap.set({'i', 't'}, '', 'j', {noremap = true})
vim.keymap.set({'i', 't'}, '', 'k', {noremap = true})
vim.keymap.set({'i', 't'}, '', 'l', {noremap = true})

-- ctrl + esc for terminal mode -> normal mode
vim.keymap.set('t', '', '', {noremap = true})

-- open terminal, stay on the script
vim.keymap.set('n', 'tT', ':vspvertical resize 85termh', {noremap = true})

-- open terminal with R
vim.keymap.set('n', 'tR', ':vspvertical resize 85term:set syntax=riRh', {noremap = true})

-- open terminal with Python and poetry environment
vim.keymap.set('n', 'tP', ':vspvertical resize 85term:set syntax=pythonisource $(poetry env info --path)/bin/activate && pythonh', {noremap = true})
```