douo / magit-gptcommit

Magit commit with help of gpt
GNU General Public License v3.0
47 stars 4 forks source link

No luck (yet) configuring this package on Doom Emacs #7

Closed hyperfocus1337 closed 6 days ago

hyperfocus1337 commented 6 days ago

Thanks for your work in this project!

I understood from your comment we should use the master branch of this project from this point onwards. And once the gptel-backend variable is configured correctly, magit-gptcommit should work as expected.

However, so far, I wasn't able to get the package commands to show inside of the magit buffer.

This is the content of my gptel-backend variable:

#s(gptel-openai "OpenRouter" "openrouter.ai" #<subr F616e6f5e796d6f797a2d6c616d626461_anonymous_lambda_12> "https" t "/api/v1/chat/completions" gptel-api-key-from-auth-source
                ("chatgpt-4o-latest" "gpt-4o-mini" "gemini-pro")
                "https://openrouter.ai/api/v1/chat/completions" nil)

This is the minimal config I'm using:

(use-package! magit-gptcommit
  :demand t
  :after magit
  :bind (:map git-commit-mode-map
              ("C-c C-g" . magit-gptcommit-commit-accept))
  :config
  ;; Enable magit-gptcommit-mode to watch staged changes and generate commit message automatically in magit status buffer
  ;; This mode is optional, you can also use `magit-gptcommit-generate' to generate commit message manually
  ;; `magit-gptcommit-generate' should only execute on magit status buffer currently
  ;; (magit-gptcommit-mode 1)
  ;; Add gptcommit transient commands to `magit-commit'
  ;; Eval (transient-remove-suffix 'magit-commit '(1 -1)) to remove gptcommit transient commands
  (magit-gptcommit-status-buffer-setup))

What am I missing? Any further guidance would be appreciated, thanks in advance!

hyperfocus1337 commented 6 days ago

Turns out, I needed to make sure I had source code staged in the Magit buffer before the package options would show. I expected the options to be there by default (but I guess I missed reading that in the setup instructions).

Above config snippet is not enough, magit-gptcommit-llm-provider also needs to be set, as I now get:

magit-gptcommit--insert: No llm provider, please configure ‘magit-gptcommit-llm-provider’.
hyperfocus1337 commented 6 days ago

Added https://github.com/douo/magit-gptcommit/issues/8 as separate issue related to the provided config example from README.md.

I will work on trying to make that work, and closing this issue.