Skip to content

viniciussoares/ai-cli.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ai-cli.nvim

Minimal Neovim plugin that runs AI CLI tools (Claude, Codex, etc.) in terminal tabs. No custom UI, no protocol, just terminal buffers.

Requirements

  • Neovim >= 0.8.0
  • CLI tools available in PATH (e.g. claude, codex)

Installation

Use any plugin manager. Example with lazy.nvim:

{
  "viniciussoares/ai-cli.nvim",
  config = function()
    require("ai-cli").setup()
  end,
}

Setup

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
  },
})

Commands

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.

Send Format

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

API

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")

Suggested keymaps

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" })

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages