https://github.com/nekowasabi/aider.vim
Helper aider with neovim
https://github.com/nekowasabi/aider.vim
ai aider chatgpt chatgpt-api claude-3-sonnet claude-ai claude-api denops neovim vim
Last synced: 24 days ago
JSON representation
Helper aider with neovim
- Host: GitHub
- URL: https://github.com/nekowasabi/aider.vim
- Owner: nekowasabi
- Created: 2024-02-19T09:10:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-15T07:34:16.000Z (about 2 months ago)
- Last Synced: 2025-09-07T23:53:28.598Z (27 days ago)
- Topics: ai, aider, chatgpt, chatgpt-api, claude-3-sonnet, claude-ai, claude-api, denops, neovim, vim
- Language: TypeScript
- Homepage:
- Size: 28.2 MB
- Stars: 88
- Watchers: 3
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# aider.vim
Minimal helper plugin for [aider](https://github.com/Aider-AI/aider) with
neovim.## Demo
You can invoke Aider from vim
You can send the selected range to Aider as context
You can send the current buffer to Aider as context
You can send voice commands to Aider using Whisper
## Requirements
- [aider](https://github.com/paul-gauthier/aider)
- [denops.vim](https://github.com/vim-denops/denops.vim)## Settings
### vimscript
Please add the following settings to your vimrc or init.vim.
```vim
" aider.vim settings
ex.
" Aider command configuration
let g:aider_command = 'aider --no-auto-commits'" Where to show Aider
" - 'floating': Neovim floating window (inside Neovim)
" - 'vsplit'/'split': If inside tmux, Aider opens in a tmux pane
let g:aider_buffer_open_type = 'floating'
let g:aider_floatwin_width = 100
let g:aider_floatwin_height = 20
let g:aider_floatwin_border = "double"
let g:aider_floatwin_border_style = "minimal"" Additional prompt setting
let g:aider_additional_prompt = [
"Your additional prompt here",
"This will be displayed in the floating window when using visual mode selections",
"You can see and edit it before sending to aider",
]" Key mappings
nnoremap at :AiderRun
" Add current file to Aider
nnoremap aa :AiderAddCurrentFile
" Add current file as read-only to Aider
nnoremap ar :AiderAddCurrentFileReadOnly
" Add Aider web interface
nnoremap aw :AiderAddWeb
" Exit Aider
nnoremap ax :AiderExit
" Add current file to Aider ignore list
nnoremap ai :AiderAddIgnoreCurrentFile
" Open Aider ignore list
nnoremap aI :AiderOpenIgnore
" Paste content from clipboard into Aider
nnoremap ap :AiderPaste
" Hide Aider window
nnoremap ah :AiderHide
" Hide Aider window in terminal mode
tnoremap :AiderHide
vmap av :AiderVisualTextWithPrompt" Autocommand group for Aider
augroup AiderOpenGroup
autocmd!
autocmd User AiderOpen call s:AiderOpenHandler()
augroup ENDfunction! s:AiderOpenHandler() abort
" Set key mappings for the Aider buffer
tnoremap
nnoremap :AiderHide
endfunction
```### lua (lazy.nvim)
Please add the following settings to your lazy settings.
```lua
{ "nekowasabi/aider.vim"
, dependencies = "vim-denops/denops.vim"
, config = function()
vim.g.aider_command = 'aider --no-auto-commits'
-- Where to show Aider
-- 'floating': inside Neovim. 'vsplit'/'split': if inside tmux, use a tmux pane
vim.g.aider_buffer_open_type = 'floating'
vim.g.aider_floatwin_width = 100
vim.g.aider_floatwin_height = 20vim.api.nvim_create_autocmd('User',
{
pattern = 'AiderOpen',
callback =
function(args)
vim.keymap.set('t', '', '', { buffer = args.buf })
vim.keymap.set('n', '', 'AiderHide', { buffer = args.buf })
end
})
vim.api.nvim_set_keymap('n', 'at', ':AiderRun', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'aa', ':AiderAddCurrentFile', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'ar', ':AiderAddCurrentFileReadOnly', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'aw', ':AiderAddWeb', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'ax', ':AiderExit', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'ai', ':AiderAddIgnoreCurrentFile', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'aI', ':AiderOpenIgnore', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'ap', ':AiderPaste', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', 'ah', ':AiderHide', { noremap = true, silent = true })
vim.api.nvim_set_keymap('v', 'av', ':AiderVisualTextWithPrompt', { noremap = true, silent = true })
end
}
```## Usage
To use aider.vim, you can run the following commands within Vim or Neovim:
`All commands with the name "Silent" send commands to aider without moving the focus to the aider buffer.`
- `:AiderRun` - Runs aider or displays the Aider UI.
- If inside tmux and `g:aider_buffer_open_type` is `split`/`vsplit`, a tmux pane is created.
- If a tmux pane for Aider already exists, it will be re-attached and shown.
- `:AiderAddCurrentFile` - Adds the current file to aider's context.
- `:AiderAddCurrentFileReadOnly` - Adds the current file as read-only to aider's
context.
- `:AiderAddBuffers` - Adds all currently open buffers under Git management to
aider's context.
- `:AiderSilentAddCurrentFile` - Without moving the focus to the aider buffer,
adds the current file to aider's context and refreshes the buffer.
- `:AiderSilentAddCurrentFileReadOnly` - Without moving the focus to the aider
buffer, adds the current file as read-only to aider's context.
- `:AiderExit` - Exits aider and cleans up the session.
- `:AiderVisualTextWithPrompt` - Edit the selected text in visual mode in a
floating window and send it to aider. In the floating window, send to aider
with `` in normal mode, and close the floating window with `Q`. You can
also backup prompt with `q`.
- `:AiderAddPartialReadonlyContext` - Adds the selected text in visual mode as
read-only context to Aider.
- `:AiderAddWeb` - Displays a prompt for the specified URL and adds it to the
aider context.
- `:AiderOpenIgnore` - Opens the `.aiderignore` file in the git root directory
if it exists.
- `:AiderAddIgnoreCurrentFile` - Adds the current file to the `.aiderignore`.
- `:AiderSendPromptByCommandline ` - Sends a prompt from the command
line and displays the Aider window.
- `:AiderSilentSendPromptByCommandline ` - Sends a prompt from the
command line and refreshes the buffer.
- `:AiderAsk ` - Sends a question to aider without adding any files to
the context.
- `:AiderHide` - Hides the Aider UI.
- Floating mode: closes the floating window and reloads the buffer.
- tmux mode: detaches the Aider pane from the current window (keeps session alive).
- `:AiderPaste` - Pastes the content from the clipboard into the aider context.
- `:AiderHideVisualSelectFloatingWindow` - Hides the visual selection floating
window used for displaying selected text.
- `:AiderVoice` - Sends voice commands to Aider (using Whisper).### tmux integration
When running inside tmux and `g:aider_buffer_open_type` is `split` or `vsplit`:
- Aider opens in a tmux pane instead of a Neovim window.
- `:AiderRun` re-attaches an existing Aider pane to the current tmux window if it exists; otherwise, it creates a new pane and launches Aider using your `$SHELL -lc` so your shell profile is respected.
- `:AiderHide` detaches the Aider tmux pane from the current window (pane stays alive and can be re-attached later by `:AiderRun`).
- Prompts, including multi-line ones, are sent to the Aider tmux pane with bracketed paste for reliability.Note: Since the UI lives in the tmux pane, Aider output will not appear in a Neovim buffer in this mode. Use `floating` to keep the UI inside Neovim.
### Advanced Usage
If you want to send a custom prompt to Aider, use
`AiderSendPromptByCommandline`. Set it up as follows:```vim
" Send a prompt to Aider and display the Aider window
:AiderSendPromptByCommandline "/chat-mode architect"" Send a prompt to Aider but do not display the Aider window
:AiderSilentSendPromptByCommandline "/chat-mode code"
```## Additional Prompt
You can set an additional prompt that will be automatically added to every
interaction with aider. This is useful for setting consistent rules or
guidelines for the AI.To use this feature, set the `g:aider_additional_prompt` variable in your vimrc
or init.vim:```vim
let g:aider_additional_prompt = [
"Your additional prompt here",
"This will be displayed in the floating window when using visual mode selections",
"You can see and edit it before sending to aider",
]
```This prompt will be displayed in the floating window when using visual mode
selections, allowing you to see and edit it before sending to aider.## ddu Source
aider.vim provides a ddu source and kind, which allows you to easily select
files from your git repository and add them to the aider context.To use this feature, you need to have
[ddu.vim](https://github.com/Shougo/ddu.vim) installed.Here's an example configuration for your ddu settings:
```vim
call ddu#custom#patch_global({
\ 'sources': [{'name': 'aider'}],
\ 'sourceOptions': {
\ 'aider': {'matchers': ['matcher_substring']},
\ },
\ 'kindOptions': {
\ 'aider': {
\ 'defaultAction': 'add',
\ },
\ },
\ })nnoremap ad
\ call ddu#start({'sources': [{'name': 'aider'}]})
```With this configuration, you can press `ad` to open ddu with the aider
source. You can then select files and press `` to add them to the aider
context.### DEMO
## Acknowledgements
Aider CLI tool created by [Paul Gauthier](https://github.com/paul-gauthier).