A Neovim plugin that integrates Aider, an AI coding assistant, directly into your editor.
While Aider is great in the terminal, making one-file code edits could be more convenient.
This plugin integrates Aider directly into Neovim, displaying changes in diff mode for easy move with ]c
, [c
, and appply changes with dp
.
For complex tasks, terminal Aider remains preferred, but this streamlines daily edits. The plugin leverages Aider's understanding of your git repository context for more precise modifications.
Created after finding no existing solutions that matched these needs. Still experimental and open to improvements.
- Neovim >= 0.10.2
- Aider installed and available in PATH
Before using aider.nvim, you need to set up your API key:
- For Anthropic models (default):
export ANTHROPIC_API_KEY=your_api_key_here
- For OpenAI models:
export OPENAI_API_KEY=your_api_key_here
Using lazy.nvim:
{
"ddzero2c/aider.nvim",
opts = {
-- Optional custom configuration
},
}
Default configuration with all available options:
require("aider").setup({
command = 'aider', -- Path to aider command
model = 'sonnet', -- AI model to use
mode = 'diff', -- Edit mode: 'diff' or 'inline'
-- Floating window options
float_opts = {
relative = 'editor',
width = 0.8, -- 80% of editor width
height = 0.8, -- 80% of editor height
style = 'minimal',
border = 'rounded',
title = ' Aider ',
title_pos = 'center',
},
})
See more models here
diff
: Shows changes in a split diff view (default)- Left window: Original
- Right window: Aider's modifications
- Use
]c
and[c
to navigate between modifications - Use
dp
to apply changes
inline
: Directly applies changes to the current file- Modifies file content immediately
- No diff view shown
- Use this mode for faster editing workflow, ideal for users who use mini.nvim
Add to your Neovim configuration:
-- Basic keymap for visual mode
vim.keymap.set({'v', 'n'}, 'ga', ':AiderEdit<CR>', { noremap = true, silent = true })
- Select code in visual mode
- Run
:AiderEdit
- Enter your prompt in the input box
- Review changes in the diff view
- Save or discard changes as needed
MIT License