Skip to content

bxrne/clank.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clank.nvim

GitHub Workflow Status Lua

clank.nvim wires AI coding "harnesses" (Claude Code, 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).

Requirements

  • Neovim >= 0.10
  • The claude CLI on your $PATH (for the default claude harness)

Installation

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 = {},
}

Setup

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

Commands

:ClankFill

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

:ClankReview {n}

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 commit
  • 2 — 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.

:ClankFix

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.

Configuration

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

Providers

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). Additional harnesses (Codex, opencode, etc.) can be added by implementing the same contract and registering under a new name.

Development

make test

Tests run via plenary.nvim + busted. The claude provider's tests stub vim.system, so no real CLI invocation or network access is required.

About

Use clankers from neovim

Topics

Resources

License

Stars

Watchers

Forks

Contributors