Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sendtoterm.nvim

Overview

Sendtoterm is a neovim plugin that allows you to:

  • send text from a buffer to a terminal (or terminals)
  • easily set up an autorun command to send a specific string to a terminal (or terminals) when a file is saved

A terminal can be:

  • a neovim terminal
  • the previous or next Zellij pane

Example usages:

  • incrementally writing or modifying a script, and testing it by sending contents to a REPL (irb, ipython, node, etc.)
  • Jupyter-style workbooks -- send ``` blocks to a repl
  • running commands on multiple terminals (e.g. locally + remote SSH server)

Usage

  1. Open neovim
  2. Open a terminal, either: a. a terminal within neovim, and run :SendtotermSet or :SendtotermAdd (add can add multiple times, so you can send text to multiple at a time) b. OR, open another terminal panel in Zellij, and run :SendtotermZNext or :SendtotermZPrev in vim, depending on whether the terminal is after of before the pane with neovim.
  3. In a neovim buffer, add some shell commands like "echo hello" and "ls". You can send text to the terminal in several ways: a. run :Sendtoterm while on the line with the shell command b. select text in visual mode and run :Sendtoterm to send the selected lines c. run :%Sendtoterm to send the whole buffer to the terminal d. it can be useful to set up a macro or shortcut key to send text in-between lines of triple backquotes. I use the following in which-key to make <Leader>T make a mark "t", selects the lines in between triple backquotes, send the lines, and return the cursor to its original position.
     ['<Leader>T' = { "mt?^ *```<CR>jVk/^ *```<CR>k:Sendtoterm<CR>:noh<CR>`t", "Send code block to terminal" },
    

Demos

Demo 1: send whole file to zellij pane with :%Sendtoterm demo 1

Demo 2: send line to multiple neovim terminals demo 2

Plugin development

Based on nvim-plugin-template

This is my first nvim plugin, so it's a little rough around the edges still.

# Run tests using nvim (might require plenary.nvim?)
make 
# Formatter, see https://github.com/JohnnyMorganz/StyLua
stylua .

About

send text from nvim buffers to terminals

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages