Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sonnet.nvim

An AI coding agent living in your current Neovim buffer, one keypress away, no context switching.

Demo

demo

The problem

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.


How it works

  1. Press <Leader>ai from any buffer
  2. A floating prompt window opens — type your instruction
  3. Press <CR> (normal mode) or <C-Enter> (insert mode) to submit
  4. A spinner appears on your cursor line while Claude thinks
  5. The response is applied directly to your buffer — new code is inserted, existing code is replaced in-place

Requirements

  • Neovim >= 0.9
  • Claude Code CLI — the claude binary must be on your $PATH
    # verify it is available
    which claude
  • An active Claude Code subscription / API key configured for the CLI

Installation

lazy.nvim (what i use anyway)

{
  "jonasjore/sonnet.nvim",
  config = function()
    require("sonnet").setup({
      keymap = "<Leader>ai",
    })
  end,
}

Keymaps inside the prompt window

Key Mode Action
<CR> Normal Submit prompt
<C-Enter> Insert Submit prompt
<Esc> Normal Cancel
<C-c> Normal / Insert Cancel

Future features

  • 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_tokens from 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.

About

Claude straight in neovim buffer

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages