Mai Pull Request is a Neovim plugin that helps you generate commit messages and pull requests directly from your Neovim editor.
- Create pull requests from within Neovim
- View diffs of staged files
- Integrates with OpenAI for PR description & commit message generation
- Neovim >= 0.7.0
- Git (installed and configured in your system)
- OpenAI API key (for PR description generation)
Using lazy.nvim
Add the following to your Neovim configuration:
{
"ryanvu/mai_pr.nvim",
config = function()
require("mai_pull_request").setup({
-- your configuration here
})
end,
dependencies = {
"MunifTanjim/nui.nvim",
},
}
You can configure Mai Pull Request by passing options to the setup
function:
require("mai_pull_request").setup({
api_key = "your-openai-api-key", -- Set your OpenAI API key here
create_commands = true, -- Set to false if you don't want to create commands
model = "gpt-4o-mini", -- OpenAI model to use
max_tokens = 4096, -- Maximum number of tokens for OpenAI requests
temperature = 0.5, -- Temperature for OpenAI requests
verbose_commit = false, -- Defaults to have non-verbose one-liner commit messages
})
After installation and configuration, you can use the following commands:
:MaiPR
: Create a new pull request for the current branch:MaiDiffToCommit
: View the diff for the current branch:MaiDiffBetweenBranches <base_branch> <branch>
: View the diff between two branches
The plugin sets up the following default keymaps:
<leader>pr
: Create a new pull request (equivalent to:MaiPR
)<leader>vd
: View diff to commit (equivalent to:MaiDiffToCommit
)
You can customize these keymaps in your Neovim configuration if desired.
Generated commit message
Diff between branches
Generated PR
If you prefer not to store your OpenAI API key in your configuration, you can set it as an environment variable:
export OPEN_AI_API_KEY=your-api-key-here
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any problems or have any questions, please open an issue on the GitHub repository.