chep / copilot-chat.el

Chat with Github copilot in Emacs !
MIT License
107 stars 14 forks source link

Copilot Chat for Emacs

Description

This plugin allows you to chat with github copilot.

copilot-chat demo

Feel free to contribute, report issues or discuss new features.

Installation

Melpa

Copilot-chat is available on melpa :

M-x package-install RET copilot-chat RET

With use-package :

(use-package copilot-chat)

Straight

(use-package copilot-chat
  :straight (:host github :repo "chep/copilot-chat.el" :files ("*.el"))
  :after (request org markdown-mode shell-maker))

Manual

Clone repository and eval files in emacs.

Configuration

Github

You will need a github acccount with access to copilot API. When sending the first prompt, you will need to authenticate to github. Follow instructions and everything will be fine.

Backend

copilot-chat-backend can be set to 'curl (default) or 'request.

With curl, answers will be written token by token. Curl path can be set with copilot-chat-curl-program variable.
With request library, the text is written when all data is read and this can be long.

Frontend

Several frontends are available. You can select your favorite one by setting the copilot-chat-frontend variable to 'markdown, 'org or 'shell-maker ( https://github.com/xenodium/chatgpt-shell ).

Try them and choose wisely.

Magit commits

You can use copilot to generate your commit messages :

(add-hook 'git-commit-setup-hook 'copilot-chat-insert-commit-message)

Or call manually (copilot-chat-insert-commit-message) when in the commit message buffer.

Proxy

The proxy can be configured with the curl backend. For the emacs-request backend, please refer to the emacs-request documentation if you need to configure a proxy.

Use the variables copilot-chat-curl-proxy, copilot-chat-curl-proxy-user-pass, and copilot-chat-curl-proxy-insecure to set up a proxy. Refer to the documentation for each variable to learn how to use them.

Proxies have not been thoroughly tested yet, so there may be bugs. Many options are missing for HTTPS proxies. Please open an issue if you need additional features.

Usage

Basic

Start chatting with copilot-chat-display. Type your question in *copilot-chat-prompt* buffer, then press C-c C-c or C-c RET.
You may need to authenticate to github. Follow instructions.

You can select buffers that will be added as context in your prompt. Use copilot-chat-add-current-buffer and copilot-chat-del-current-buffer. You can also manage buffers by using copilot-chat-list.
Selected buffers will be sent with each prompt until you remove them.

Functions

Key bindings

Warning : key bindings have changed since Melpa integration needs to avoid C-c <letter> bindings.

Prompt buffer

Chat buffer

Buffer list buffer

Notes

This plugin is unofficial and based on Copilot Chat for neovim repository: https://github.com/CopilotC-Nvim/CopilotChat.nvim

The prompt for git commit messages comes from gpt-commit.

For github copilot code completion in emacs, checkout copilot.el