cook.nvim is a modular and extensible Neovim plugin that lets you effortlessly compile or run the current file based on its filetype — inside a floating terminal.
Supports:
- 🐍 Python
- 🦀 Rust
- 🧠 C/C++
- 🌀 JavaScript / TypeScript
- 🦫 Go
- 📂 Runs code from the current buffer based on its extension
- 🪟 Opens a floating terminal inside Neovim
- ⚙️ Easily extendable for any language
- 📦 Define per-project tasks with
recipes.lua - 🧠 Smart filetype-to-runner resolution
- 📋
:Coopmode for Competitive Programming - ❗ Tasks starting with
!run as native Vim commands — useful for plugins likecmake-tools.nvim - 💡 Minimal setup, pure Lua
{
"07CalC/cook.nvim",
config = function()
require("cook").setup()
end,
cmd = "Cook",
}use {
"07CalC/cook.nvim",
config = function()
require("cook").setup()
end
}:help cookIn any buffer, simply run:
:CookIt will:
- Detect the filetype by extension.
- Build the appropriate shell command.
- Open a floating terminal and run it.
If your project has a recipes.lua in its root, you can:
:Cook dev
:Cook buildDefine custom tasks at the project root (detected via .git or recipes.lua) using a recipes.lua file:
--- recipes.lua
return {
recipes = {
dev = "cargo watch -x run"
build = "cargo build --release"
test = "cargo test"
fmt = "cargo fmt"
cmake_build = "!CMakeBuild" -- runs as a Vim command
}
}📝 Note:
- Commands starting with
!are executed usingvim.cmd(), letting you run Vim-native or plugin-provided commands. - Use keymap
<ESC><ESC>to leave terminal mode. - Use command
:Cooktor keymap<leader><leader>tto toggle terminal.
Competitive programming guys, this is for you. Just copy the input (from a problem description) to clipboard, then run:
:CoopIt will:
- Detect your filetype.
- Create a temp file with clipboard contents.
- Pipe the input to your program (< input.in).
- Show the output in a terminal buffer.
You can configure your own runners, but here are the defaults:
runners = {
py = "python3 %s",
c = "gcc %s -o %s && %s",
cpp = "g++ %s -o %s && %s",
rs = "cargo run",
js = "bun %s",
ts = "bun %s",
go = "go run %s",
}You can customize this via:
require("cook").setup({
runners = {
py = "python %s",
sh = "bash %s",
},
})By default, cook.nvim opens a floating terminal, but you can change this behavior to suit your workflow.
float→ centered floating terminal (default)bottom→ splits and runs in bottom windowvertical→ opens terminal in a vertical split
require("cook").setup({
terminal = {
layout = "float", -- or "bottom", "vertical"
width = 0.8, -- used for floating and vertical layout
height = 0.3, -- used for floating and bottom layout
border = "rounded", -- border style for floating terminal
},
})lua/
└── cook/
├── init.lua -- Entry point
├── config.lua -- Plugin config and default runners
├── filetype.lua -- Filetype-based runner resolution
├── executor.lua -- Terminal execution
├── commands.lua -- Maps user commands (Cook, Coop)
└── recipes.lua -- Project-local task loader
PRs are welcome! You can:
- Add support for more languages
- Improve command detection
- Add UI options (like vertical split)


