Skip to content
This repository was archived by the owner on Mar 15, 2024. It is now read-only.

Commit 19c5f40

Browse files
committed
chore: add more docs
1 parent 7e3048d commit 19c5f40

File tree

3 files changed

+47
-15
lines changed

3 files changed

+47
-15
lines changed

README.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
<h1 align="center">commit-msg-sg.nvim</h2>
33
</p>
44

5-
<p align="center">
6-
Write git commit message with AI (sg.nvim).
7-
</p>
5+
Write git commit message with AI ([sg.nvim](https://github.com/sourcegraph/sg.nvim), [Cody](https://sourcegraph.com/cody)).
86

97
<div align="center">
108
> Drag your video (<10MB) here to host it for free on GitHub.
@@ -34,8 +32,34 @@ Snippet
3432
```lua
3533
{
3634
'towry/commit-msg-sg.nvim',
35+
dependencies = {
36+
'sourcegraph/sg.nvim',
37+
},
38+
-- all options are optional, you can leave it as empty table `{}`.
3739
opts = {
38-
-- see doc
40+
cwd = function()
41+
return vim.uv.cwd()
42+
end,
43+
-- auto attach on gitcommit filetype.
44+
auto_setup_gitcommit = true,
45+
-- auto create user command `WriteGitCommitMessage`.
46+
auto_setup_command = true,
47+
-- callback when AI is started and attached to current buffer. (client, bufnr)
48+
-- You can create your own buffer local commands or keymaps in this callback.
49+
on_attach = nil,
50+
-- Ghost text that will be presenting when AI is working.
51+
ghost_text = "Thinking...",
52+
-- function to generate prompt string.
53+
-- accept a callback that takes input as prompt string.
54+
-- prompt_gen = function(callback)
55+
-- -- some async operation to generate prompt.
56+
-- local generated_prompt_string = 'The prompt string ...'
57+
-- callback(error_or_nil, generated_prompt_string)
58+
-- end
59+
prompt_gen = nil,
60+
-- default prompt string if you do not want to use prompt_gen.
61+
-- default_prompt = [[Some prompt string ... The diff content is: %s]]
62+
default_prompt = nil,
3963
},
4064
cmd = { 'WriteGitCommitMessage' },
4165
ft = 'gitcommit',
@@ -62,11 +86,3 @@ Snippet
6286
## ⌨ Contributing
6387

6488
PRs and issues are always welcome. Make sure to provide as much context as possible when opening one.
65-
66-
## 🗞 Wiki
67-
68-
You can find guides and showcase of the plugin on [the Wiki](https://github.com/towry/commit-msg-sg.nvim/wiki)
69-
70-
## 🎭 Motivations
71-
72-
> If alternatives of your plugin exist, you can provide some pros/cons of using yours over the others.

lua/commit-msg-sg/config.lua

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,31 @@ local CommitMsgSg = {}
55
--- Default values:
66
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
77
CommitMsgSg.options = {
8-
---@type string|function
8+
-- Can be string or function that returns cwd.
9+
--@type string|function
910
cwd = nil,
11+
-- auto attach on gitcommit filetype.
1012
auto_setup_gitcommit = true,
13+
-- auto create user command `WriteGitCommitMessage`.
1114
auto_setup_command = true,
15+
-- callback when AI is started and attached to current buffer. (client, bufnr)
16+
-- You can create your own buffer local commands or keymaps in this callback.
1217
on_attach = nil,
1318
ghost_text = "Thinking...",
14-
-- customized function to generate prompt string.
19+
-- function to generate prompt string.
20+
-- accept a callback that takes input as prompt string.
21+
-- ```lua
22+
-- prompt_gen = function(callback)
23+
-- -- some async operation to generate prompt.
24+
-- local generated_prompt_string = 'The prompt string ...'
25+
-- callback(error_or_nil, generated_prompt_string)
26+
-- end
27+
-- ```
1528
prompt_gen = nil,
29+
-- default prompt string if you do not want to use prompt_gen.
30+
-- default_prompt = [[Some prompt string ... The diff content is: %s]]
31+
-- Note: the staged diff content is generated so you can use it in your prompt to
32+
-- add more context.
1633
default_prompt = nil,
1734
-- @private
1835
executor = "sg",

lua/commit-msg-sg/init.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ function M.write()
101101

102102
local executor = require("commit-msg-sg.executor")
103103
gen_snippet(config.options, function(err, snippet)
104-
print(snippet)
105104
if err then
106105
vim.notify(err, vim.log.levels.ERROR)
107106
return

0 commit comments

Comments
 (0)