Vimini is a Vim plugin that provides seamless integration with Google's Gemini (Generative AI) models, allowing you to interact with AI directly from your Vim editor. You can chat, generate code, list available models, and get code reviews without leaving your coding environment.
- Chat with Gemini: Send prompts and receive responses in a new buffer.
- Context-Aware Code Generation: Use all open buffers as context to generate code.
- Code Review: Get AI-powered reviews for the code in your current buffer or from your git history.
- Git Integration: Generate commit messages and view diffs using AI.
- List Models: Easily view all available Gemini models.
- API Key Management: Configure your Gemini API key securely.
- Live "Thinking" View: Optionally watch the AI's thought process in real-time during code generation.
- Vim (or Neovim) with Python 3 support.
- Python 3.6+
- The
google-genaiPython library. You can install it via pip:pip install google-genai
gitmust be installed and in yourPATHfor the Git-related commands.
You can install Vimini using your preferred Vim plugin manager.
Using Vim-Plug:
- Add the following line to your
.vimrcorinit.vim:call plug#begin() Plug 'your-github-username/vimini.vim' " Replace with the actual repo path call plug#end()
- Run
:PlugInstallin Vim.
Using Packer.nvim:
- Add the following to your
init.lua(for Neovim) orplugins.lua:use 'your-github-username/vimini.nvim' " Replace with the actual repo path
- Run
:PackerSyncor:PackerInstallin Neovim.
(Note: Replace your-github-username/vimini.vim with the actual
repository path once published.)
Vimini requires your Google Gemini API key and a default model to function.
-
API Key (
g:vimini_api_key): You can set your API key directly in your.vimrcorinit.vim:let g:vimini_api_key = 'YOUR_API_KEY_HERE'
Alternatively, Vimini will also look for the API key in a file named
~/.config/gemini.token. This is the recommended and more secure approach. Just place your API key (and nothing else) into that file:# ~/.config/gemini.token YOUR_API_KEY_HERE -
Default Model (
g:vimini_model): Specify the default Gemini model you want to use. The default isgemini-2.5-flash. You can list available models using:ViminiListModels.let g:vimini_model = 'gemini-2.5-flash' " Or 'gemini-2.5-pro', etc.
-
Thinking Display (
g:vimini_thinking): Control whether the AI's "thinking" process is displayed in a separate buffer during code generation." Show the 'Vimini Thoughts' buffer. (Default) let g:vimini_thinking = 'on' " Hide the 'Vimini Thoughts' buffer. let g:vimini_thinking = 'off'
This can also be controlled with the
:ViminiThinkingcommand.
Vimini exposes several commands for interacting with the Gemini API:
Lists all available Gemini models in a new split window. This is
useful for knowing which models you can set for g:vimini_model.
:ViminiListModelsSends a prompt to the configured Gemini model and displays the AI's
response in a new vertical split buffer.
:ViminiChat What is the capital of France?Toggles or sets the display of the AI's real-time thought process
during code generation. When enabled, a Vimini Thoughts buffer will
appear alongside the Vimini Code buffer.
" Toggle the current setting (on -> off, off -> on)
:ViminiThinking
" Explicitly turn the thinking display on
:ViminiThinking on
" Explicitly turn the thinking display off
:ViminiThinking offTakes the content of all open buffers as context, along with your
prompt, and asks the Gemini model to generate code. The result is
streamed into several new buffers:
Vimini Code: The generated code.Vimini Diff: A diff view comparing the original code with the AI's suggestion.Vimini Thoughts(Optional): Ifg:vimini_thinkingison(the default), this buffer shows the AI's internal monologue as it works.
This command is ideal for asking the AI to refactor, debug, or extend your current code.
:ViminiCode Please refactor this function to be more conciseAfter running :ViminiCode, you can use one of the following commands to
apply the changes:
Replaces the entire content of your original buffer with the
AI-generated code from the Vimini Code buffer. It then closes the
temporary Vimini Code, Vimini Diff, and Vimini Thoughts buffers.
Appends the AI-generated code to the end of your original buffer. This
is useful when you've asked the AI to add a new function or class. It
also closes the temporary Vimini Code, Vimini Diff, and Vimini Thoughts buffers.
Sends content to the Gemini model for a code review. This command has two modes:
- Current Buffer Review: If no
git_objectsare provided, it sends the content of the current buffer for review. - Git Object Review: If the command starts with
C:<git_objects>, it reviews the output ofgit show <git_objects>.<git_objects>can be any valid git object reference, like a commit hash, branch name, orHEAD~1.
In both cases, you can add an optional {prompt} to guide the AI's review. The review and suggestions will be displayed in a new vertical split buffer.
Examples:
" Review the current buffer for performance issues
:ViminiReview Check for performance issues.
" Perform a general review of the current buffer
:ViminiReview
" Review the changes in the latest commit
:ViminiReview C:HEAD
" Review changes from two commits ago and ask for security vulnerabilities
:ViminiReview C:HEAD~2 "Check for security vulnerabilities"Vimini offers commands to integrate with your Git workflow.
Shows the output of git diff for the current repository in a new
split window. This allows you to see unstaged changes without leaving
Vim.
:ViminiDiffAutomates the commit process using AI. This command:
- Stages all current changes (
git add .). - Generates a conventional commit message (subject and body) based on the staged diff.
- Displays the generated message in a popup for you to confirm (
y) or cancel (n). - If confirmed, it commits the changes with the generated message and
a
Co-authored-by: Geminitrailer.
:ViminiCommitMost of the code here is generated by Gemini itself, I only provide guidance and occasioanly edit some small bit where it is easier then asking
Also, it's important to remember that AI, much like a well-fed cat, requires a steady stream of attention and high-quality prompts to perform its best tricks. Neglect it, and you might just find it napping on your keyboard when you need it most. -- Simo.