clank.nvim wires AI coding "harnesses" (Claude Code and opencode, with more
planned) into
Neovim through a small provider abstraction, so you can send a visual
selection to the model and have the result applied directly to your buffer
(reversible with normal u undo).
- Neovim >= 0.10
- The
claudeCLI on your$PATH(for the defaultclaudeharness), or theopencodeCLI (for theopencodeharness)
With vim.pack (Neovim >= 0.12):
vim.pack.add({
"https://github.com/bxrne/clank.nvim",
})
require("clank").setup()With lazy.nvim:
{
"bxrne/clank.nvim",
opts = {},
}require("clank").setup({
harness = "claude", -- which provider to dispatch to
model = "sonnet-4.6",
keymaps = {
fill = "<leader>af", -- visual-mode keymap, set to false to disable
},
})Send the current visual selection to the configured harness, asking it to
fill in / complete the selected code, and replace the selection with the
response. Also bound to the keymaps.fill keymap (default <leader>af) in
visual mode.
Usage: select a block (e.g. an empty function body) in visual mode, then
press <leader>af (or run :ClankFill).
Send a git diff to the configured harness for review and load its comments
into the quickfix list. Requires git to be on $PATH and the current
working directory to be inside a git repository.
The required integer argument selects what to review:
0— uncommitted changes (staged and unstaged)1— the most recent commit2— the commit before that- ...and so on
The harness is asked to respond with one path:line: message line per
issue, which is parsed straight into the quickfix list (:copen to view).
Usage: :ClankReview 0 to review your working tree changes, :ClankReview 1
to review the last commit, etc.
Send the buffers referenced by the quickfix list to the configured harness, asking it to fix the listed issues, and replace each buffer's contents with the response.
Run :ClankFix with no range to fix every entry in the quickfix list.
Alternatively, from the quickfix window (:copen), select a range of lines
in visual mode and run :'<,'>ClankFix to fix only those entries.
Give the configured harness a free-form task in natural language. The harness
explores the repository as needed and responds with a structured plan of
Neovim actions, which clank then executes for you. Because the default
claude harness is agentic, it can read files and run git while deciding what
to do.
:ClankDo review all the hotspots and add them to my quickfix list
:ClankDo rename the Config type to ClankConfig everywhere
:ClankDo open a vertical split with the busiest source file
The harness must reply with a JSON object, { "actions": [ ... ] }, where each
action is one of:
{ "type": "command", "command": "<ex command>" }— run an Ex command (e.g.copen,vsplit foo.lua).{ "type": "qflist", "action": "r"|"a", "items": [...] }— replace (r) or append (a) quickfix items ({ filename, lnum, text }).{ "type": "edit", "path": "<path>", "content": "<full new contents>" }— overwrite a file's buffer with new contents (reversible withu).
Before anything runs, clank shows the plan and asks for confirmation. Set
agent.confirm = false to apply plans without prompting.
| Option | Type | Default | Description |
|---|---|---|---|
harness |
string |
"claude" |
Provider used to handle requests |
model |
string |
"sonnet-4.6" |
Model passed to the harness |
keymaps.fill |
string|false |
"<leader>af" |
Visual-mode keymap for :ClankFill, false to disable |
agent.confirm |
boolean |
true |
Confirm before running a :ClankDo action plan |
Providers are registered against lua/clank/provider/init.lua's registry and
implement a send(opts, callbacks) contract:
-- opts: { prompt, system?, session_id?, cwd }
-- callbacks: { on_chunk(text), on_done(result), on_error(err) }
-- returns a handle with handle.cancel()The built-in claude provider shells out to the claude CLI in headless
mode (claude -p ... --output-format text). The built-in opencode provider
shells out to opencode run ...; its models are addressed as provider/model
(e.g. anthropic/claude-sonnet-4-5), and any provider/model string is
accepted. Additional harnesses (Codex, etc.) can be added by implementing the
same contract and registering under a new name.
To use opencode:
require("clank").setup({
harness = "opencode",
model = "anthropic/claude-sonnet-4-5",
})make testTests run via plenary.nvim +
busted. The claude provider's tests stub vim.system, so no real CLI
invocation or network access is required.