Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samharju/yeet.nvim
Plugin for running shell commands in terminal buffers or tmux panes.
https://github.com/samharju/yeet.nvim
neovim-lua-plugin neovim-plugin neovim-plugins
Last synced: 7 days ago
JSON representation
Plugin for running shell commands in terminal buffers or tmux panes.
- Host: GitHub
- URL: https://github.com/samharju/yeet.nvim
- Owner: samharju
- License: mit
- Created: 2024-02-03T16:36:17.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-10-27T12:39:20.000Z (13 days ago)
- Last Synced: 2024-10-27T14:17:35.872Z (12 days ago)
- Topics: neovim-lua-plugin, neovim-plugin, neovim-plugins
- Language: Lua
- Homepage:
- Size: 72.3 KB
- Stars: 89
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - samharju/yeet.nvim - Run shell commands in terminal buffers or tmux panes. (Terminal Integration / CSV Files)
README
# Yeet.nvim
* [Usecase](#usecase)
* [Installation](#installation)
* [lazy.nvim](#lazynvim)
* [packer](#packer)
* [Docs](#docs)
* [Configuration](#configuration)
* [Harpoon](#harpoon)## Usecase
![tmux2](https://github.com/user-attachments/assets/51e8bcf9-2e68-40f6-a88a-f5f9cde5f42f)
Plugin for running shell commands in terminal buffers or tmux panes.
There are many great plugins for integrating test tools and build systems into Neovim. I wanted to
have something super simple that works out of the box for any language or project by just utilizing
existing basic bash commands, shell scripts and makefiles, with absolutely zero configuration.
Just open a menu, write command, execute somewhere. It's a bonus to have project local command
history also available when needed.Yeet sends the command provided to whatever terminal buffer or tmux pane selected as target. There
is no feedback loop, so indication of success or failure of given task is not given. After initial
command/target selection just keep hammering `:Yeet` or your preferred keymap.Demo:
https://github.com/user-attachments/assets/de628d05-d314-4ba5-a948-a6f6bd8db646
## Installation
### lazy.nvim
```lua
{
"samharju/yeet.nvim",
dependencies = {
"stevearc/dressing.nvim", -- optional, provides sane UX
},
version = "*", -- use the latest release, remove for master
cmd = "Yeet",
opts = {},
}
```### packer
```lua
use({
"samharju/yeet.nvim",
requires = {
"stevearc/dressing.nvim", -- optional, provides sane UX
},
tag = "*", -- use the latest release, remove for master
cmd = "Yeet",
config = function()
require("yeet").setup({})
end,
})
```## Docs
`:h yeet.nvim` or [doc/yeet.txt](doc/yeet.txt)
## Configuration
Default options:
```lua
{
opts = {
-- Send to channel after command for immediate execution.
yeet_and_run = true,
-- Send C-c before execution
interrupt_before_yeet = false,
-- Send 'clear' to channel before command for clean output.
clear_before_yeet = true,
-- Enable notify for yeets. Success notifications may be a little
-- too much if you are using noice.nvim or fidget.nvim
notify_on_success = true,
-- Print warning if pane list could not be fetched, e.g. tmux not running.
warn_tmux_not_running = false,
-- Resolver for cache file
cache = function()
-- resolves project path and uses stdpath("cache")/yeet/, see :h yeet
end
-- Use cache.
cache = true
-- Window options for cache float
cache_window_opts = {
relative = "editor",
row = (vim.o.lines - 15) * 0.5,
col = (vim.o.columns - math.ceil(0.6 * vim.o.columns)) * 0.5,
width = math.ceil(0.6 * vim.o.columns),
height = 15,
border = "single",
title = "Yeet",
},
}
}
```Example keymappings:
```lua
{
keys = {
{
-- Pop command cache open
"",
function() require("yeet").list_cmd() end,
},
{
-- Open target selection
"yt", function() require("yeet").select_target() end,
},
{
-- Douple tap \ to yeet at something
"\\\\", function() require("yeet").execute() end,
},
{
-- Toggle autocommand for yeeting after write
"yo", function() require("yeet").toggle_post_write() end,
},
{
-- Run command without clearing terminal, send C-c
"\\", function()
require("yeet").execute(nil, { clear_before_yeet = false, interrupt_before_yeet = true })
end,
},
{
-- Yeet visual selection. Useful sending core to a repl or running multiple commands.
"yv",
function() require("yeet").execute_selection({ clear_before_yeet = false }) end,
mode = { "n", "v" },
},
}
}```
Options can be passed directly to `Yeet.execute` for overriding something for specific command.
If you often need the same chore command in many projects, you can create a keymap with fixed
command:```lua
vim.keymap.set("n", "yy", function()
require("yeet").execute(
"source venv/bin/activate",
{ clear_before_yeet = false }
)
end)
```## Harpoon
Implementing some kind of Yeet-specific logic for keeping track of project local commands, syncing
them on disk etc. extra hustle wasn't earlier on the feature list. I used the newly reworked
[harpoon2](https://github.com/ThePrimeagen/harpoon) for persistence backend for my commands. Harpoon
caches project specific named lists, so you can just open the list, have it run `Yeet.execute` on
select and then just keep repeating that latest command with your preferred keymap for
`Yeet.execute`. You can also use numerous list customization features, list local keymaps etc with
harpoon.```lua
{
"theprimeagen/harpoon",
branch = "harpoon2",
dependencies = {
"nvim-lua/plenary.nvim",
"samharju/yeet.nvim",
},
config = function()
local harpoon = require("harpoon")
harpoon:setup({
yeet = {
select = function(list_item, _, _)
require("yeet").execute(list_item.value)
end,
},
})vim.keymap.set( "n", "",
function() harpoon.ui:toggle_quick_menu(harpoon:list("yeet")) end
)-- other harpoon keymaps etc
-- ...
end,
}```