1- *codecompanion-gitcommit.txt* For Neovim >= 0.8.0 Last change: 2024 Dec 19
1+ *codecompanion-gitcommit.txt* For Neovim >= 0.8.0 Last change: 2025 Jun 02
22
33CODECOMPANION GIT COMMIT EXTENSION *codecompanion-gitcommit*
44
@@ -36,6 +36,8 @@ analyze your staged changes and create appropriate commit messages.
3636• Automatic git repository detection
3737• Support for both user commands and slash commands
3838• Smart keymap integration for gitcommit buffers
39+ • Multi-language support for commit messages
40+ • Support for both regular commits and `git commit --amend`
3941
4042==============================================================================
41433. INSTALLATION *codecompanion-gitcommit-install*
@@ -64,11 +66,12 @@ Add this extension to your CodeCompanion configuration:
6466==============================================================================
65674. CONFIGURATION *codecompanion-gitcommit-config*
6668
67- The extension accepts the following configuration options:
68-
69- *codecompanion-gitcommit-opts*
69+ The extension accepts the following configuration options: *codecompanion-gitcommit-opts*
7070opts = {
7171 add_slash_command = false, -- Add /gitcommit slash command to chat buffer
72+ adapter = "openai", -- LLM adapter to use (optional)
73+ model = "gpt-4", -- Model to use (optional)
74+ languages = { "English", "简体中文", "日本語" }, -- Languages for commit messages (optional)
7275 buffer = {
7376 enabled = true, -- Enable gitcommit buffer keymaps
7477 keymap = "<leader> gc", -- Keymap for generating commit message
@@ -83,6 +86,29 @@ add_slash_command *gitcommit-add-slash-command*
8386 When enabled, adds `/gitcommit` slash command to CodeCompanion chat
8487 buffers for generating commit messages within chat sessions.
8588
89+ adapter *gitcommit-adapter*
90+ Type: string
91+ Default: codecompanion chat adapter
92+ The LLM adapter to use for generating commit messages. If not
93+ specified, defaults to the adapter configured for CodeCompanion's
94+ chat strategy.
95+
96+ model *gitcommit-model*
97+ Type: string
98+ Default: codecompanion chat model
99+ The specific model to use with the adapter. If not specified,
100+ defaults to the model configured for CodeCompanion's chat strategy.
101+
102+ languages *gitcommit-languages*
103+ Type: table
104+ Default: nil (English only)
105+ A list of languages that can be used for generating commit messages.
106+ When specified, the extension will prompt you to select a language
107+ before generating the commit message. If not provided or empty,
108+ commit messages will be generated in English by default.
109+
110+ Example: { "English", "简体中文", "日本語", "Français" }
111+
86112buffer.enabled *gitcommit-buffer-enabled*
87113 Type: boolean
88114 Default: true
@@ -139,6 +165,15 @@ GitCommit Buffer Workflow:~
1391654. The AI-generated message will be inserted into the buffer
1401665. Edit if needed and save to complete the commit
141167
168+ Amend Workflow:~
169+ 1. Make additional changes to your files
170+ 2. Stage changes with `git add` (optional, for new changes)
171+ 3. Run `git commit --amend` to open the amend buffer
172+ 4. Press `<leader> gc` in normal mode to generate an updated commit message
173+ 5. The extension will analyze the full commit changes and generate an
174+ appropriate message
175+ 6. Edit if needed and save to complete the amend
176+
142177==============================================================================
1431786. COMMANDS *codecompanion-gitcommit-commands*
144179
@@ -155,18 +190,30 @@ GitCommit Buffer Workflow:~
155190
156191The extension provides a programmatic API for advanced usage:
157192
158- gitcommit.generate({callback} ) *gitcommit.generate()*
159- Generate a commit message asynchronously.
193+ gitcommit.generate({lang} , { callback} ) *gitcommit.generate()*
194+ Generate a commit message asynchronously with optional language support .
160195
161196 Parameters:~
197+ {lang} string|nil: Language to generate commit message in
198+ (optional, uses default if nil)
162199 {callback} function: Callback function that receives
163200 (result, error) parameters
164201
165202 Example:~
166203>lua
167204 local gitcommit = require("codecompanion").extensions.gitcommit
168205
169- gitcommit.generate(function(result, error)
206+ -- Generate with specific language
207+ gitcommit.generate("简体中文", function(result, error)
208+ if error then
209+ print("Error:", error)
210+ else
211+ print("Generated:", result)
212+ end
213+ end)
214+
215+ -- Generate with default language
216+ gitcommit.generate(nil, function(result, error)
170217 if error then
171218 print("Error:", error)
172219 else
@@ -208,37 +255,49 @@ gitcommit.get_buffer_config() *gitcommit.get_buffer_config()*
208255The extension consists of the following modules:
209256
210257lua/codecompanion/_extensions/gitcommit/
211- ├── init.lua # Main extension entry point
212- ├── git.lua # Git operations (repository detection, diff, commit)
258+ ├── init.lua # Main extension entry point and command registration
259+ ├── git.lua # Git operations (repository detection, diff, commit, amend support )
213260├── generator.lua # LLM integration for commit message generation
214261├── ui.lua # Floating window UI and interactions
215262├── buffer.lua # GitCommit buffer keymap integration
216- ├── types .lua # Type definitions and constants
217- └── test .lua # Test utilities and functions
263+ ├── langs .lua # Language selection functionality
264+ └── types .lua # Type definitions and TypeScript-style annotations
218265
219266Module Overview:~
220267
221268git.lua~
222269 Handles all git-related operations including repository detection,
223- staged changes retrieval, and commit execution.
270+ staged changes retrieval, commit execution, and `git commit --amend`
271+ support. Includes contextual diff analysis and error handling.
224272
225273generator.lua~
226274 Manages LLM interaction including prompt creation for commit message
227- generation, API communication with CodeCompanion adapters, and
228- response handling.
275+ generation with language support , API communication with CodeCompanion
276+ adapters, response handling, and adapter/model configuration .
229277
230278ui.lua~
231- Provides interactive user interface including floating window display,
232- keyboard shortcuts, and copy to clipboard functionality.
279+ Provides interactive user interface including floating window display
280+ with markdown formatting, interactive keyboard shortcuts, copy to
281+ clipboard functionality, and responsive window sizing.
233282
234283buffer.lua~
235284 Handles gitcommit buffer integration including automatic keymap setup
236- for gitcommit filetype, smart commit message insertion, and buffer
237- content management.
285+ for gitcommit filetype, smart commit message insertion at correct
286+ position, buffer content management, and language selection integration.
287+
288+ langs.lua~
289+ Manages language selection functionality including multi-language
290+ support configuration, interactive language selection UI, and
291+ language preference handling.
292+
293+ types.lua~
294+ Provides TypeScript-style type annotations for Lua including interface
295+ definitions for all modules and configuration option types.
238296
239297init.lua~
240- Main extension coordinator that handles module integration, command
241- registration, and extension exports.
298+ Main extension coordinator that handles module integration, dependency
299+ management, command registration, slash command integration, and
300+ extension exports for programmatic usage.
242301
243302==============================================================================
2443039. REQUIREMENTS *codecompanion-gitcommit-requirements*
0 commit comments