VimAid.Demo.mov
VimAid is a lightweight Neovim plugin (written in vimscript, for no good reason) that opens a modal window connected to aider-chat, enabling you to ask questions directly about the file you're currently working on. Its goal is to streamline the process of querying and interacting with aider-chat for code assistance, without leaving your Neovim environment.
- Aider-Chat Integration: Opens a modal terminal in Neovim where you can directly ask questions about your active file in
aider-chat. - Context-Aware Queries: Easily ask questions about the current file, such as "What does this file do?" or "How can I optimize this function?"
- Simple Workflow: With a single command (
:Aid), you can load your current file intoaider-chatand immediately start interacting.
To use VimAid, you'll need the following installed and set up on your machine:
-
Neovim (v0.5 or higher)
- Neovim is required for its floating terminal support. To install Neovim, follow the instructions for your operating system:
-
Tmux (v3.0 or higher)
- Tmux is used for managing sessions within the plugin. You can install Tmux using your system's package manager:
- Tmux GitHub Repository and Installation Instructions
- Example installation via Homebrew (macOS):
brew install tmux
- Note: If you're using iTerm2 on macOS, tmux is already integrated and no further configuration is necessary. You can use tmux within iTerm2 without needing to install it separately.
- Tmux is used for managing sessions within the plugin. You can install Tmux using your system's package manager:
-
Aider-Chat (Local Setup)
- Aider-Chat must be installed and working on your local machine. Follow the guide on how to set up Aider:
- Aider Installation Guide (or a relevant URL to the official Aider setup guide).
- Aider-Chat must be installed and working on your local machine. Follow the guide on how to set up Aider:
Once you have these prerequisites installed and configured, you're ready to install VimAid.
-
Add the following line to your
init.vimor.vimrc:Plug 'SamStuckey/VimAid' -
Run the following command in Neovim to install the plugin:
:PlugInstall
-
Add the following line to your
init.luaorinit.vim:use 'SamStuckey/VimAid'
-
Run the following command in Neovim to install the plugin:
:PackerSync
-
Navigate to your
bundledirectory:cd ~/.vim/bundle
-
Clone the VimAid repository:
git clone https://github.com/SamStuckey/VimAid.git
-
Make sure Pathogen is correctly set up in your
.vimrc:execute pathogen#infect()
:Aid: This command opens a floating terminal window, runsaider-chat, and automatically loads the file you're currently working on in Neovim into theaider-chatsession. Once the modal is open, you can ask questions like:- "What does this file do?"
- "How can I refactor this method?"
- "Are there any syntax errors in this file?"
- Additionally,
aider-chatcan make changes to your file and even commit those changes. This allows for a seamless workflow where you not only receive suggestions but can also apply those suggestions directly.
If you're interested in learning more about what aider-chat can and cannot do, please refer to the Aider-Chat Documentation for detailed information.
- Open a file in Neovim, e.g.,
my_file.rb. - If you have a question about the file, simply run
:Aid. - The plugin will open
aider-chatin a floating terminal withmy_file.rbalready loaded. - You can now ask
aider-chatquestions directly, like "What does this file do?" or even instruct it to modify the file and commit changes.
VimAid runs in a terminal mode modal, and by default, closing the modal requires a lengthy key sequence: Cmd+Leader, Cmd+n, :q, <CR>. To streamline this, you can use the variable g:vimaid_close_modal_mapping to define a custom key mapping that allows you to quickly close the modal with a single command.
For example, in your vimrc (or equivalent), you can define the following:
let g:vimaid_close_modal_mapping = '<C-a>'
nnoremap <C-a> :Aid<CR>These two mappings allows you to use Ctrl + a to quickly open and close the modal (without loosing your chat history) and return to your normal workflow, avoiding the default key sequence.
You can replace <C-a> with any key combination of your choice to suit your preferences.
If you prefer to use the default key mapping, simply run the command :Aid or define your own mappings like so:
nnoremap <Leader>aid :Aid<CR>This is a small personal project, and at the moment, contributions are not being accepted.