Exploring copilot for Emacs

First off, I hadn't set up straight, so I did that:

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
         'silent 'inhibit-cookies)
      (goto-char (point-max))
  (load bootstrap-file nil 'nomessage))

Then I installed copilot:

(use-package copilot
  :straight (:host github :repo "zerolfx/copilot.el" :files ("dist" "*.el"))
  :ensure t)

I enabled it for all programming modes:

(add-hook 'prog-mode-hook 'copilot-mode)

I prefer company-mode for completion, so I enabled copilot to use it:

(with-eval-after-load 'company
  ;; disable inline previews
  (delq 'company-preview-if-just-one-frontend company-frontends))

(define-key copilot-completion-map (kbd "<tab>") 'copilot-accept-completion)
(define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion)

In advance, I had signed up for copilot on github.com, so I just had to use M-x copilot-login to log in. In the browser, I just pasted in the one time code Emacs had put on the clipboard.

The last bit I did, was to enable copilot all over the place: M-x copilot-global-mode.

That was it. I was ready to use copilot.

Licensed under CC BY Creative Commons License ~ ✉ torstein.k.johansen @ gmail ~ 🐘 @skybert@emacs.ch ~ 🐦 @torsteinkrause