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

Latest commit

 

History

History
93 lines (76 loc) · 2.38 KB

File metadata and controls

93 lines (76 loc) · 2.38 KB

commit-msg-sg.nvim

Write git commit message with AI (sg.nvim, Cody).

msg-sg-2023-12-26.10.32.31.mp4

📋 Installation

Package manager Snippet

folke/lazy.nvim

Checkout usage examples ->

{
  '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',
}

☄ Getting started

  1. Open git commit buffer in your neovim.
  2. run :WriteGitCommitMessage.

🧰 Commands

Command Description
:WriteGitCommitMessage Let AI write the git commit message for you

⌨ Contributing

PRs and issues are always welcome. Make sure to provide as much context as possible when opening one.