Sengoku11/commitpad.nvim

github github
git
stars 8
issues 0
subscribers 1
forks 0
CREATED

UPDATED


CommitPad

commitpad.nvim

A lightweight popup for writing Git commit messages directly within Neovim.

It facilitates a descriptive commit style (e.g. Mitchell Hashimoto) by providing a dedicated writing environment.

CommitPad focuses on one thing: delivering the best commit experience. It doesn't replace a full Git toolkit.

Features

  • Markdown Buffer: The input is a filetype=markdown buffer, enabling your formatters, linters, snippets, and LSP.
  • Persistent & Isolated Drafts: Stored in your .git directory (.git/commitpad/ or .git/worktrees/<name>/commitpad/).
    • No .gitmessage clutter or .gitignore pollution.
    • Drafts are isolated per worktree and persist across sessions.
  • Visual Validation:
    • Real-time highlighting of title length to assist with 50/72 rule.
    • Flags non-conventional commit types (e.g., doc: vs docs:) and structural breaks in the type[scope][!]: description format.
  • Streamlined Workflow:
    • Non-blocking async UI.
    • Seamless navigation between panes with hjkl.
    • Start amend mode with the previous commit message.
    • Amend and push in one step, avoiding manual git push --force-with-lease.
    • View and stage files in optional Git status pane.
    • Automatically carry over tags (e.g., Signed-off-by) between commits.

Why CommitPad?

  • Vs fugitive: Preserves your window layout by using a floating overlay instead of disruptive splits.
  • Vs $EDITOR: Instantly summon and dismiss your draft with a dedicated toggle (<leader>gc).
  • Vs lazygit: Leverages your full Neovim setup (LSP, spell check), avoiding the overhead of a TUI context switch.
  • Vs git commit -m: Enables iterative drafting and multiline formatting, rather than hasty one-liners.

Installation

Lazy.nvim

{
  "Sengoku11/commitpad.nvim",
  dependencies = { "MunifTanjim/nui.nvim" },
  cmd = { "CommitPad", "CommitPadAmend" },
  keys = {
    { "<leader>gc", "<cmd>CommitPad<cr>", desc = "CommitPad" },
    { "<leader>gac", "<cmd>CommitPadAmend<cr>", desc = "CommitPadAmend" },
  },
  opts = {
    -- Recommended options
    stage_files = true, -- Display staged files in UI so you can stage/unstage without leaving the popup
  },
}

Default Options

opts = {
  footer = false, -- A dedicated buffer that provides a "sticky" area for repetitive tags
  stage_files = false, -- Display staged files in UI (Git status pane)
  hints = {
    controls = true, -- Display control hints in the popup border
    titles = true, -- Display annotations in popup titles
    diff_counts = true, -- Display +added -deleted lines count in status headers
  },
  mappings = {
    commit = "<leader><CR>",
    commit_and_push = "<leader>gp",
    clear_or_reset = "<C-l>",
    jump_to_status = "<leader>l",
    jump_to_input = "<leader>h",
    stage_toggle = "s", -- Stage/Unstage file in the status pane when stage_files = true
  },
}

Requirements

Recommended Configuration

For the best experience writing prose in the popup, these settings are recommended.

Neovim Options

-- Soft wrap lines at word boundaries, preserving indentation
vim.opt.wrap = true -- Enable soft wrap (required for the options below)
vim.opt.breakindent = true -- Visual indentation matches the code level
vim.opt.linebreak = true -- Wrap at words, not arbitrary characters

-- Builtin spell check
vim.opt.spell = true
vim.opt.spelllang = { "en_us" }
vim.opt.spelloptions = "camel"

Suggested Plugins