Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ require("copilot").setup {
}
```

### git commit messages

When editing a commit message (`gitcommit` filetype), Copilot uses the staged
diff (`git diff --staged`) to generate commit message suggestions. Enable
`gitcommit` in the `filetypes` table to use this feature.

### logger

Logs will be written to the `file` for anything of `file_log_level` or higher.
Expand Down
5 changes: 5 additions & 0 deletions doc/copilot.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ won’t be used anymore. e.g.
}
<

GIT COMMIT MESSAGES~

When editing a commit message (`gitcommit` filetype), Copilot fetches the
staged diff (`git diff --staged`) to provide commit message suggestions. Enable
`gitcommit` in the |copilot-filetypes| table to use this feature.

LOGGER ~

Expand Down
7 changes: 7 additions & 0 deletions lua/copilot/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ function M.get_doc()
position = params.position,
}

if vim.bo.filetype == "gitcommit" then
local ok, diff = pcall(vim.fn.system, { "git", "diff", "--staged", "--no-color" })
if ok and diff and diff ~= "" then
doc.gitDiff = diff
end
end

return doc
end

Expand Down