Skip to content

automatically generates commit messages using ChatGPT API

License

Notifications You must be signed in to change notification settings

ktakayama/gpt-commit-msg.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gpt-commit-msg.vim

gpt-commit-msg is a Vim plugin that automatically generates Git commit messages using the OpenAI ChatGPT API based on the changes in git diff --cached.

2023-03-06.15.51.40.mov

Requirement

  • curl

Installation

You can use the plugin manager or Vim8 package manager. eg: dein.vim

[[plugins]]
repo = 'ktakayama/gpt-commit-msg.vim'

Once you have installed the plugin, you will need to set up an API key from OpenAI. You can do this by following the instructions on the OpenAI website.

Configuration

You can configure this plugin by setting the following variables in your .vimrc:

Required

let g:gpt_commit_msg = {}
let g:gpt_commit_msg.api_key = "<YOUR_API_KEY>"

Optional

" ID of the model to use
let g:gpt_commit_msg.api_model = "gpt-3.5-turbo"

" The maximum number of lines of Git diff text to send to the ChatGPT API
let g:gpt_commit_msg.max_lines_to_send = 2000

" A function to filter the generated commit message
function! g:gpt_commit_msg.result_filter(text) abort
  return substitute(a:text, '^\(.\)', '\L\1', '')
endfunction

" Example for Custom mapping in result window
augroup GPTCommitMsg
  autocmd!
  autocmd FileType gpt-commit-msg-result nnoremap <silent><buffer>q :<C-u>bwipeout!<CR>
augroup END

Usage

To use this plugin, simply run the :GPTCommitMsg command while in a Git repository. This will generate a commit message based on the changes made in the repository.

After running :GPTCommitMsg you will see a results window with the commit messages generated. Move the cursor over the message you like and <CR> to yank it.

About

automatically generates commit messages using ChatGPT API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published