Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A CodeCompanion extension that generates AI-powered git commit messages followin
## Features

- 🤖 AI-powered commit message generation using CodeCompanion's LLM adapters
- 📋 Interactive UI with copy and commit options
- 📋 Interactive UI with copy to clipboard and yank register options
- ✅ Conventional Commits specification compliance
- 🔍 Automatic git repository detection
- 📝 Support for both user commands and slash commands
Expand Down Expand Up @@ -128,8 +128,8 @@ Manages LLM interaction:
Provides interactive user interface:

- Floating window display with markdown formatting
- Interactive keyboard shortcuts (`c`, `s`, `Enter`, `q/Esc`)
- Copy to clipboard functionality
- Interactive keyboard shortcuts (`c`, `y`, `s`, `Enter`, `q/Esc`)
- Copy to clipboard and yank register functionality
- Responsive window sizing

### `buffer.lua`
Expand Down Expand Up @@ -176,10 +176,21 @@ Main extension coordinator:
3. Review the generated commit message in the floating window
4. Choose an action:
- `c` - Copy to clipboard
- `y` - Copy to yank register
- `s` - Submit (commit changes)
- `Enter` - Copy and close
- `q/Esc` - Close without action

### Interactive Keymaps

When the floating window is displayed with the generated commit message, the following keymaps are available:

- **`c`** - Copy the commit message to the system clipboard (`+` register)
- **`y`** - Copy the commit message to Vim's default yank register (`"` register)
- **`s`** - Submit the commit message immediately (executes `git commit`)
- **`Enter`** - Copy to clipboard and close the floating window
- **`q` or `Esc`** - Close the floating window without taking any action

### GitCommit Buffer Workflow
1. Stage your changes with `git add`
2. Run `git commit` to open the commit buffer
Expand Down
30 changes: 28 additions & 2 deletions doc/codecompanion-gitcommit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ analyze your staged changes and create appropriate commit messages.
2. FEATURES *codecompanion-gitcommit-features*

• AI-powered commit message generation using CodeCompanion's LLM adapters
• Interactive UI with copy and commit options
• Interactive UI with copy to clipboard and yank register options
• Conventional Commits specification compliance
• Automatic git repository detection
• Support for both user commands and slash commands
Expand Down Expand Up @@ -154,6 +154,7 @@ Traditional Workflow:~
3. Review the generated commit message in the floating window
4. Choose an action:
• `c` - Copy to clipboard
• `y` - Copy to yank register
• `s` - Submit (commit changes)
• `Enter` - Copy and close
• `q/Esc` - Close without action
Expand All @@ -174,6 +175,31 @@ Amend Workflow:~
appropriate message
6. Edit if needed and save to complete the amend

5.5 Interactive Keymaps *codecompanion-gitcommit-keymaps*

When the floating window is displayed with the generated commit message,
the following keymaps are available:

`c` *gitcommit-keymap-c*
Copy the commit message to the system clipboard. This uses the `+`
register and also copies to `*` register if clipboard support is
available.

`y` *gitcommit-keymap-y*
Copy the commit message to Vim's default yank register (`"`). This
allows you to paste the message using `p` or `P` commands within Vim.

`s` *gitcommit-keymap-s*
Submit the commit message immediately. This will execute `git commit`
with the generated message and close the floating window if successful.

`<Enter>` *gitcommit-keymap-enter*
Copy the commit message to clipboard (same as `c`) and close the
floating window.

`q` or `<Esc>` *gitcommit-keymap-q*
Close the floating window without taking any action.

==============================================================================
6. COMMANDS *codecompanion-gitcommit-commands*

Expand Down Expand Up @@ -278,7 +304,7 @@ generator.lua~
ui.lua~
Provides interactive user interface including floating window display
with markdown formatting, interactive keyboard shortcuts, copy to
clipboard functionality, and responsive window sizing.
clipboard and yank register functionality, and responsive window sizing.

buffer.lua~
Handles gitcommit buffer integration including automatic keymap setup
Expand Down
10 changes: 10 additions & 0 deletions lua/codecompanion/_extensions/gitcommit/generator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,21 @@ Please only return a commit message that strictly follows the Conventional Commi
4. Body (optional): use bullet points (-) to list specific changes

Example format:

feat(scope): add new feature

- implement X functionality
- update Y module
- add tests for Z

The message need follow this :

<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>

Note: You need to answer in %s.

Based on the git diff provided below, generate a standardized commit message.
Expand Down
8 changes: 7 additions & 1 deletion lua/codecompanion/_extensions/gitcommit/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function UI._prepare_content(message)
table.insert(content, "## Actions")
table.insert(content, "")
table.insert(content, "- **[c]** Copy to clipboard")
table.insert(content, "- **[y]** Copy to yank register")
table.insert(content, "- **[s]** Submit (commit changes)")
table.insert(content, "- **[Enter]** Copy and close")
table.insert(content, "- **[q/Esc]** Close")
Expand Down Expand Up @@ -126,12 +127,17 @@ function UI._setup_keymaps(buf, win, message, on_commit)
vim.api.nvim_win_close(win, true)
end, opts)

-- Copy to clipboard
vim.keymap.set("n", "c", function()
copy_to_clipboard(message)
vim.notify("📋 Commit message copied to clipboard", vim.log.levels.INFO)
end, opts)

-- Copy to yank register
vim.keymap.set("n", "y", function()
vim.fn.setreg('"', message)
vim.notify("📝 Commit message copied to yank register", vim.log.levels.INFO)
end, opts)

-- Submit commit
vim.keymap.set("n", "s", function()
local success = on_commit(message)
Expand Down