-
I've played around with the built-in
I find it awkward. Ideally, I'd like to:
Or, even better:
I've found two discussion threads (one, two) about this topic, but none of them got any traction. I also did not find any discussion of Git commit flow in the documentation. Therefore, I'm trying to craft my own prompt. So far I have the following: prompt_library = {
['Commit Message'] = {
strategy = 'inline',
description = 'Generate a commit message',
opts = {
short_name = 'commit_message',
auto_submit = true,
placement = 'replace',
},
prompts = {
{
role = 'user',
content = function()
return string.format(
[[You are an expert at following the Conventional Commit specification. Given the git diff listed below, please generate a commit message for me:
` ` `diff
%s
` ` `
When unsure about the module names to use in the commit message, you can refer to the last 20 commit messages in this repository:
` ` `
%s
` ` `
Output only the commit message without any explanations and follow-up suggestions.
]],
vim.fn.system('git diff --no-ext-diff --staged'),
vim.fn.system('git log --pretty=format:"%s" -n 20')
)
end,
opts = {
contains_code = true,
},
},
},
},
}, The prompt uses:
With this prompt I'm getting close to my ideal flow. The only annoyance is that after the generated message is placed in the So I guess my questions are:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I was just struggling with this as well. I found the following comment which mentions a placement of "before|false". I have no idea what exactly that mean, but it seems to do the trick. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the pointer, that does the trick indeed! |
Beta Was this translation helpful? Give feedback.
-
Is this a more sensible default than generating commit messages in chat? @olimorris |
Beta Was this translation helpful? Give feedback.
I was just struggling with this as well. I found the following comment which mentions a placement of "before|false". I have no idea what exactly that mean, but it seems to do the trick.
#92 (comment)