Never write commit messages again! This Neovim plugin analyzes your staged git changes and generates multiple AI-powered commit messages. Simply stage your changes, run :AICommit, and select from 4 professionally crafted commit messages in a beautiful modal interface.
Perfect for developers who want consistent, high-quality commit messages without the mental overhead of writing them manually.
- 🤖 Generate commit messages using OpenAI GPT models
- 🎯 Modal selection interface with 4 suggested messages
- ⚡ Asynchronous generation (non-blocking)
- 📏 Conventional commit format support
- 🚀 Optional auto-push after commit
- ⚙️ Configurable AI model and parameters
- Neovim >= 0.8.0
- Git
- OpenAI API key
Using lazy.nvim
{
'JanSmrcka/nvim-auto-commit',
config = function()
require('nvim-auto-commit').setup({
-- Optional configuration
})
end
}Using packer.nvim
use {
'JanSmrcka/nvim-auto-commit',
config = function()
require('nvim-auto-commit').setup()
end
}For local testing:
-- lazy.nvim
{
dir = '/path/to/your/nvim-auto-commit',
config = function()
require('nvim-auto-commit').setup()
end
}
-- packer.nvim
use {
'/path/to/your/nvim-auto-commit',
config = function()
require('nvim-auto-commit').setup()
end
}-
Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY="your-api-key-here"
-
Configure the plugin (optional):
require('nvim-auto-commit').setup({ openai_api_key = nil, -- Uses OPENAI_API_KEY env var by default openai_model = 'gpt-3.5-turbo', -- OpenAI model to use max_commit_messages = 4, -- Number of suggestions to generate conventional_commits = true, -- Use conventional commit format auto_push = false, -- Auto-push after commit temperature = 0.7, -- AI creativity (0.0-1.0) })
- Stage your changes:
git add .orgit add <files> - Generate commit messages: Run
:AICommitin Neovim - Select and commit: Choose from 4 AI-generated options:
- Press
1,2,3, or4to select instantly - Use arrow keys +
Enterto navigate and select - Press
qorEscto cancel
- Press
That's it! Your commit is created automatically with the selected message.
$ git add src/auth.lua
$ nvim
:AICommit
┌─────── Select Commit Message ───────┐
│ 1. feat(auth): add login validation │
│ 2. fix(auth): resolve session bug │
│ 3. refactor: improve auth logic │
│ 4. chore(auth): update dependencies │
│ │
│ Press number (1-4) to select, q to quit │
└─────────────────────────────────────┘
:AICommit- Generate and select AI commit messages
"OPENAI_API_KEY not configured"
- Set your API key:
export OPENAI_API_KEY="sk-..." - Or configure in plugin setup:
openai_api_key = "sk-..."
"No staged changes found"
- Stage your changes first:
git add .orgit add <files> - Check status:
git status
"Failed to generate commit messages"
- Check your internet connection
- Verify your OpenAI API key is valid
- Try a smaller diff (large diffs are automatically truncated)
The AI analyzes your actual code changes and generates contextual commit messages:
For adding a new feature:
feat(auth): add JWT token validationfeat(api): implement user registration endpointfeat(ui): add loading spinner component
For bug fixes:
fix(database): resolve connection timeout issuefix(validation): handle empty email inputfix(memory): prevent leak in event listeners
For refactoring:
refactor(utils): simplify date formatting logicrefactor(components): extract reusable button componentrefactor(api): consolidate error handling
| Option | Default | Description |
|---|---|---|
openai_api_key |
$OPENAI_API_KEY |
Your OpenAI API key |
openai_model |
'gpt-3.5-turbo' |
OpenAI model to use |
max_commit_messages |
4 |
Number of commit messages to generate |
conventional_commits |
true |
Use conventional commit format |
auto_push |
false |
Automatically push after commit |
temperature |
0.7 |
AI creativity level (0.0-1.0) |
MIT