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
2
2
3
3
CODECOMPANION GIT COMMIT EXTENSION *codecompanion-gitcommit*
4
4
@@ -36,6 +36,8 @@ analyze your staged changes and create appropriate commit messages.
36
36
• Automatic git repository detection
37
37
• Support for both user commands and slash commands
38
38
• Smart keymap integration for gitcommit buffers
39
+ • Multi-language support for commit messages
40
+ • Support for both regular commits and `git commit --amend`
39
41
40
42
==============================================================================
41
43
3. INSTALLATION *codecompanion-gitcommit-install*
@@ -64,11 +66,12 @@ Add this extension to your CodeCompanion configuration:
64
66
==============================================================================
65
67
4. CONFIGURATION *codecompanion-gitcommit-config*
66
68
67
- The extension accepts the following configuration options:
68
-
69
- *codecompanion-gitcommit-opts*
69
+ The extension accepts the following configuration options: *codecompanion-gitcommit-opts*
70
70
opts = {
71
71
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)
72
75
buffer = {
73
76
enabled = true, -- Enable gitcommit buffer keymaps
74
77
keymap = "<leader> gc", -- Keymap for generating commit message
@@ -83,6 +86,29 @@ add_slash_command *gitcommit-add-slash-command*
83
86
When enabled, adds `/gitcommit` slash command to CodeCompanion chat
84
87
buffers for generating commit messages within chat sessions.
85
88
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
+
86
112
buffer.enabled *gitcommit-buffer-enabled*
87
113
Type: boolean
88
114
Default: true
@@ -139,6 +165,15 @@ GitCommit Buffer Workflow:~
139
165
4. The AI-generated message will be inserted into the buffer
140
166
5. Edit if needed and save to complete the commit
141
167
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
+
142
177
==============================================================================
143
178
6. COMMANDS *codecompanion-gitcommit-commands*
144
179
@@ -155,18 +190,30 @@ GitCommit Buffer Workflow:~
155
190
156
191
The extension provides a programmatic API for advanced usage:
157
192
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 .
160
195
161
196
Parameters:~
197
+ {lang} string|nil: Language to generate commit message in
198
+ (optional, uses default if nil)
162
199
{callback} function: Callback function that receives
163
200
(result, error) parameters
164
201
165
202
Example:~
166
203
>lua
167
204
local gitcommit = require("codecompanion").extensions.gitcommit
168
205
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)
170
217
if error then
171
218
print("Error:", error)
172
219
else
@@ -208,37 +255,49 @@ gitcommit.get_buffer_config() *gitcommit.get_buffer_config()*
208
255
The extension consists of the following modules:
209
256
210
257
lua/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 )
213
260
├── generator.lua # LLM integration for commit message generation
214
261
├── ui.lua # Floating window UI and interactions
215
262
├── 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
218
265
219
266
Module Overview:~
220
267
221
268
git.lua~
222
269
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.
224
272
225
273
generator.lua~
226
274
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 .
229
277
230
278
ui.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.
233
282
234
283
buffer.lua~
235
284
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.
238
296
239
297
init.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.
242
301
243
302
==============================================================================
244
303
9. REQUIREMENTS *codecompanion-gitcommit-requirements*
0 commit comments