An AI coding agent living in your current Neovim buffer, one keypress away, no context switching.
Jumping between the editor and a browser-based AI chat breaks flow. Copy code, switch window, paste, read the reply, switch back, apply it manually — the interruption adds up. sonnet.nvim solves this by putting a prompt window on a single hotkey (<Leader>ai by default). Write what you need, hit Enter, and the change lands in your buffer. Eyes stay on the code.
- Press
<Leader>aifrom any buffer - A floating prompt window opens — type your instruction
- Press
<CR>(normal mode) or<C-Enter>(insert mode) to submit - A spinner appears on your cursor line while Claude thinks
- The response is applied directly to your buffer — new code is inserted, existing code is replaced in-place
- Neovim >= 0.9
- Claude Code CLI — the
claudebinary must be on your$PATH# verify it is available which claude - An active Claude Code subscription / API key configured for the CLI
{
"jonasjore/sonnet.nvim",
config = function()
require("sonnet").setup({
keymap = "<Leader>ai",
})
end,
}| Key | Mode | Action |
|---|---|---|
<CR> |
Normal | Submit prompt |
<C-Enter> |
Insert | Submit prompt |
<Esc> |
Normal | Cancel |
<C-c> |
Normal / Insert | Cancel |
-
Claude API integration — replace the CLI subprocess with direct API calls to maintain a conversation context window across multiple prompts in the same session; currently each prompt is stateless
-
Token usage tracking — surface
input_tokens+output_tokensfrom the API response; display the running session total in the statusline (lualine / heirline component) so you always know what you are spending -
Visual mode support — select a region in visual mode before opening the prompt, so Claude operates only on the selected lines rather than inferring context from the cursor
-
Streaming output — render Claude's response token-by-token into the buffer as it arrives instead of waiting for the full response
-
Diff preview — show a diff of proposed changes in a floating window before applying; accept with
<CR>, reject with<Esc> -
Prompt history — cycle through previous prompts inside the prompt window with
<Up>/<Down> -
:checkhealth sonnet— built-in health module that verifies CLI availability, API key, and Neovim version at a glance
Warning
Work in progress. This plugin is under active development and you will likely encounter bugs. If something breaks or you have ideas, please open an issue on GitHub or reach out directly at jonas.jore@gmail.com. Contributions and feedback are very welcome.
