Minimal Neovim plugin that runs AI CLI tools (Claude, Codex, etc.) in terminal tabs. No custom UI, no protocol, just terminal buffers.
- Neovim >= 0.8.0
- CLI tools available in PATH (e.g.
claude,codex)
Use any plugin manager. Example with lazy.nvim:
{
"viniciussoares/ai-cli.nvim",
config = function()
require("ai-cli").setup()
end,
}require("ai-cli").setup({
tools = {
claude = { cmd = "claude", enabled = true },
codex = { cmd = "codex", enabled = true },
mycli = { cmd = "mycli --flag", enabled = true },
},
send_context = true,
open_mode = "tabpage", -- or "buffer" for bufferline-style tabs
terminal_mappings = {
exit = "<Esc>", -- leave terminal-mode
send_escape = "<C-c>", -- send Escape to the CLI
close = "<leader>x", -- kill the CLI session
enter = "<CR>", -- enter terminal-mode from normal mode
},
})For each enabled tool:
:Claude,:Codex- Toggle the tool terminal tab (open if not running):ClaudeLine,:CodexLine- Send visual selection to the tool:ClaudeFile,:CodexFile- Send entire current file
Custom tools get commands based on the config key. For example, a tool named
mytool becomes :MyTool, :MyToolLine, and :MyToolFile.
When send_context = true, the payload is prefixed with the current file path:
/full/path/to/file.lua:10-25 = selected code here\nmore lines
If the selection is the entire file, only the path is sent:
/full/path/to/file.lua
For multi-line selections, the payload is sent with a fenced block:
/full/path/to/file.lua:10-20
line1
line2
line3
For full file sends (:ClaudeFile / :CodexFile):
/full/path/to/file.lua
local ai = require("ai-cli")
ai.setup(opts)
ai.toggle("claude")
ai.send("claude", line1, line2)
ai.send_file("claude")
ai.is_running("claude")
ai.kill("claude")vim.keymap.set("n", "<leader>ac", "<cmd>Claude<cr>", { desc = "Toggle Claude" })
vim.keymap.set("v", "<leader>as", "<cmd>ClaudeLine<cr>", { desc = "Send to Claude" })
vim.keymap.set("n", "<leader>af", "<cmd>ClaudeFile<cr>", { desc = "Send file to Claude" })MIT