nvim-git-utils
June 30, 2026 · View on GitHub
Simple commands to make life easier while working with git.
Why I Built This?
Those commands were already present in my config so I think moving them to new plugin will make the config cleaner and makes it easy for me to share commands with others.
Features
- Interactive Commit Messages - Beautiful popup UI for writing commit messages with:
- Title/body split layout
- Character counter
- Visual warning when over limit
- Keyboard hints
- Automatic emojification (with devmoji)
- AI-Powered Commit Messages - Auto-generate commit messages from your diff using opencode
- Quick Staging & Commit - Stage all changes and commit in one command
- Amend Commits - Easily change the last commit message
- Open Changed Files - Load all modified and untracked files into buffers
- Open File in browser - Quickly open current buffer into browser
- Telescope and Diffview Integration - Browse file history and compare branches via telescope and diffview
Commands
| Command | Description |
|---|---|
:GitCommit | Commit staged changes with a message |
:GitAddCommit | Stage all changes and commit |
:GitChangeLastCommit | Amend the last commit message |
:GitAICommit | AI-generate commit message from staged diff |
:GitAIAddCommit | Stage all, then AI-generate commit message |
:GitChanges / :GitOpenChangedFiles | Open all changed files into buffers |
:GitOpen | Open current file in browser |
:DiffviewFileHistoryTelescope | Select a file and view its history |
:DiffviewCompareBranchesTelescope | Compare branches in diffview |
Installation
Using LazyVim:
return {
"bibekbhusal0/nvim-git-utils",
opts = {}, -- Your config here, see down for options and default settings
cmd = {
"GitAddCommit",
"GitCommit",
"GitChangeLastCommit",
"GitAICommit",
"GitAIAddCommit",
"GitChanges",
"GitOpen",
"DiffviewCompareBranchesTelescope",
"DiffviewFileHistoryTelescope",
},
keys = { -- Set custom keymaps for your liking
{ "<leader>gc", ":GitAddCommit<CR>", desc = "Git add and commit" },
{ "<leader>gC", ":GitCommit<CR>", desc = "Git commit" },
{ "<leader>ge", ":GitChangeLastCommit<CR>", desc = "Git change last commit message" },
{ "<leader>ga", ":GitAICommit<CR>", desc = "Git AI commit" },
{ "<leader>gA", ":GitAIAddCommit<CR>", desc = "Git AI add and commit" },
{ "<leader>gg", ":GitChanges<CR>", desc = "Git open changed files" },
{ "<leader>gO", ":GitOpen<CR>", desc = "Git open current file in browser" },
{ "<leader>gdb", ":DiffviewCompareBranchesTelescope<CR>", desc = "Diffview compare branches" },
{
"<leader>gdF",
":DiffviewFileHistoryTelescope<CR>",
desc = "Diffview file history telescope",
},
},
dependencies ={
"MunifTanjim/nui.nvim", -- for commit input
"nvim-telescope/telescope.nvim", -- for diffview telescope commands
"sindrets/diffview.nvim", -- for diffview telescope commands
}
}
Default Values
require("nvim-git-utils").setup({
log = { enabled = true, icon = "" },
commit_input = {
max_length = 72,
format_message = require("nvim-git-utils.utils.emojify"), -- Uses devmoji to add emojis to commit messages
hints = true,
},
ai_commit = {
prompt = "Generate a git commit message for the following diff. Keep the title under {max_length} characters and use the body for details when needed. Use conventional commits format (e.g., feat:, fix:, chore:, docs:, perf:, refactor:, style:, test:). Return only the commit message with no surrounding quotes or backticks.",
},
})
Setup
Configure nvim-git-utils with the following options:
require("nvim-git-utils").setup({
-- Logging configuration
log = {
enabled = true, -- Enable/disable notifications. Set to false to disable all log messages
icon = "", -- Icon prefix displayed before log messages in notifications
},
-- Commit input popup configuration
commit_input = {
max_length = 72, -- Maximum character limit for commit title
-- Set to 0 or nil to disable the character counter entirely
-- Function to transform commit message before committing
-- Set to nil to disable message formatting (returns message as-is)
-- Example with devmoji (this function is also available at require("nvim-git-utils.utils.emojify")):
-- format_message = function(msg)
-- local handle = io.popen("devmoji --text " .. vim.fn.shellescape(msg))
-- local result = handle:read("*a")
-- handle:close()
-- return result:match("^%s*(.-)%s*$")
-- end,
format_message = nil,
hints = true, -- Show keyboard shortcuts hints at the bottom of the popup
-- Set to false to hide the hints bar
},
-- AI commit message generation (requires opencode: https://opencode.ai)
ai_commit = {
-- Prompt template sent to opencode along with the diff.
-- {max_length} is replaced with commit_input.max_length at runtime.
prompt = "Generate a git commit message for the following diff. Keep the title under {max_length} characters and use the body for details when needed. Use conventional commits format (e.g., feat:, fix:, chore:, docs:, perf:, refactor:, style:, test:). Return only the commit message with no surrounding quotes or backticks.",
},
})
Credits
Main inspiration came from commitpad.nvim which allowed creating nice UI while creating new commit message with body.
Similar Plugins
How is this different from commitpad?
Commitpad is a simple and nice plugin for creating new commit messages. This plugin has additional functionalities like:
- Changing the last commit message
- Staging all files and committing in one step
- Integration with devmoji
Commitpad has a nice UI for committing but lacks customization. This plugin allows customizing:
- Max character length for commit titles
- Hiding keyboard hints
Dependencies
- nui.nvim - UI components
- telescope.nvim - Fuzzy finder
- diffview.nvim - Diff viewer
- devmoji (optional) - Emojify your commit messages
License
MIT