From e10f36500af21c6998cba6c1416820b2706e0d28 Mon Sep 17 00:00:00 2001 From: Zelong Kuang Date: Sun, 16 Nov 2025 16:19:37 +1100 Subject: [PATCH] Copilot --- config.el | 18 ++++++++++++++++++ config.org | 28 +++++++++++++++++++++++++++- packages.el | 3 +++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/config.el b/config.el index bd37f18..ced63ed 100644 --- a/config.el +++ b/config.el @@ -16,3 +16,21 @@ (when (eq system-type 'darwin) (define-key eat-semi-char-mode-map (kbd "C-h") #'eat-self-input) (define-key eat-semi-char-mode-map (kbd "") (kbd "C-h")))) + +;; accept completion from copilot and fallback to company +(use-package! copilot + :hook (prog-mode . copilot-mode) + :bind (:map copilot-completion-map + ("" . 'copilot-accept-completion) + ("TAB" . 'copilot-accept-completion) + ("C-TAB" . 'copilot-accept-completion-by-word) + ("C-" . 'copilot-accept-completion-by-word) + ("C-n" . 'copilot-next-completion) + ("C-p" . 'copilot-previous-completion)) + + :config + (add-to-list 'copilot-indentation-alist '(prog-mode 2)) + (add-to-list 'copilot-indentation-alist '(org-mode 2)) + (add-to-list 'copilot-indentation-alist '(text-mode 2)) + (add-to-list 'copilot-indentation-alist '(clojure-mode 2)) + (add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2))) diff --git a/config.org b/config.org index c81d613..117fd2e 100644 --- a/config.org +++ b/config.org @@ -1,5 +1,4 @@ * My doom config - ** Appearance settings #+begin_src emacs-lisp (setq doom-font (font-spec :family "Maple Mono" :size 20)) @@ -42,3 +41,30 @@ Fix the issue that backspace doesn't work on mac (define-key eat-semi-char-mode-map (kbd "C-h") #'eat-self-input) (define-key eat-semi-char-mode-map (kbd "") (kbd "C-h")))) #+end_src + +*** Copilot +#+begin_src emacs-lisp :tangle packages.el +(package! copilot + :recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el"))) +#+end_src + +Configuration +#+begin_src emacs-lisp +;; accept completion from copilot and fallback to company +(use-package! copilot + :hook (prog-mode . copilot-mode) + :bind (:map copilot-completion-map + ("" . 'copilot-accept-completion) + ("TAB" . 'copilot-accept-completion) + ("C-TAB" . 'copilot-accept-completion-by-word) + ("C-" . 'copilot-accept-completion-by-word) + ("C-n" . 'copilot-next-completion) + ("C-p" . 'copilot-previous-completion)) + + :config + (add-to-list 'copilot-indentation-alist '(prog-mode 2)) + (add-to-list 'copilot-indentation-alist '(org-mode 2)) + (add-to-list 'copilot-indentation-alist '(text-mode 2)) + (add-to-list 'copilot-indentation-alist '(clojure-mode 2)) + (add-to-list 'copilot-indentation-alist '(emacs-lisp-mode 2))) +#+end_src diff --git a/packages.el b/packages.el index 5c9d289..998acff 100644 --- a/packages.el +++ b/packages.el @@ -7,3 +7,6 @@ ("terminfo/65" "terminfo/65/*") ("integration" "integration/*") (:exclude ".dir-locals.el" "*-tests.el")))) + +(package! copilot + :recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el")))