Write git commit message with AI (sg.nvim, Cody).
msg-sg-2023-12-26.10.32.31.mp4
Package manager | Snippet |
---|---|
{
'towry/commit-msg-sg.nvim',
dependencies = {
'sourcegraph/sg.nvim',
},
-- all options are optional, you can leave it as empty table `{}`.
opts = {
cwd = function()
return vim.uv.cwd()
end,
-- auto attach on gitcommit filetype.
auto_setup_gitcommit = true,
-- auto create user command `WriteGitCommitMessage`.
auto_setup_command = true,
-- callback when AI is started and attached to current buffer. (client, bufnr)
-- You can create your own buffer local commands or keymaps in this callback.
on_attach = nil,
-- Ghost text that will be presenting when AI is working.
ghost_text = "Thinking...",
-- function to generate prompt string.
-- accept a callback that takes input as prompt string.
-- prompt_gen = function(callback)
-- -- some async operation to generate prompt.
-- local generated_prompt_string = 'The prompt string ...'
-- callback(error_or_nil, generated_prompt_string)
-- end
prompt_gen = nil,
-- default prompt string if you do not want to use prompt_gen.
-- default_prompt = [[Some prompt string ... The diff content is: %s]]
default_prompt = nil,
},
cmd = { 'WriteGitCommitMessage' },
ft = 'gitcommit',
} |
- Open git commit buffer in your neovim.
- run
:WriteGitCommitMessage
.
Command | Description |
---|---|
:WriteGitCommitMessage |
Let AI write the git commit message for you |
PRs and issues are always welcome. Make sure to provide as much context as possible when opening one.