|
1 | | -;;; packages.el --- Large GitHub Copilot Client for Spacemacs -*- lexical-binding: nil; -*- |
| 1 | +;;; packages.el --- Large GitHub Copilot Client for Spacemacs -*- lexical-binding: t; -*- |
2 | 2 | ;; |
3 | 3 | ;; Copyright (c) 2012-2025 Sylvain Benner & Contributors |
4 | 4 | ;; |
|
22 | 22 |
|
23 | 23 |
|
24 | 24 | (defconst github-copilot-packages |
25 | | - '((copilot))) |
| 25 | + '((copilot) |
| 26 | + (copilot-chat))) |
26 | 27 |
|
27 | 28 | (defun github-copilot/init-copilot () |
| 29 | + "Initialize the `copilot' package and set up keybindings." |
28 | 30 | (use-package copilot |
29 | | - :hook '(prog-mode-hook . copilot-mode) |
| 31 | + :hook (prog-mode . copilot-mode) |
30 | 32 | :custom |
31 | 33 | (copilot-enable-predicates '(spacemacs//copilot-enable-predicate |
32 | 34 | copilot--buffer-changed)) |
33 | 35 | :defer t |
34 | 36 | :config |
35 | | - (with-eval-after-load 'company |
36 | | - (define-key copilot-completion-map (kbd "C-<iso-lefttab>") 'github-copilot/next-completion) |
37 | | - (define-key copilot-completion-map (kbd "C-M-<iso-lefttab>") 'github-copilot/previous-completion) |
38 | | - (define-key copilot-completion-map (kbd "C-M-<return>") 'copilot-accept-completion) |
39 | | - (define-key copilot-completion-map (kbd "C-M-S-<return>") 'copilot-accept-completion-by-word)))) |
| 37 | + (define-key copilot-completion-map (kbd "C-M-<tab>") 'spacemacs/github-copilot-next-completion) |
| 38 | + (define-key copilot-completion-map (kbd "C-M-<iso-lefttab>") 'spacemacs/github-copilot-previous-completion) |
| 39 | + (define-key copilot-completion-map (kbd "C-M-<return>") 'copilot-accept-completion) |
| 40 | + (define-key copilot-completion-map (kbd "C-M-S-<return>") 'copilot-accept-completion-by-word))) |
40 | 41 |
|
41 | | -(defun github-copilot/next-completion () |
42 | | - "Move to the next completion in the Copilot completion menu. |
43 | | -This function will make sure to show the next completion, |
44 | | -if necessary triggering a `copilot-complete' command beforehand." |
45 | | - (interactive) |
46 | | - (copilot-complete) |
47 | | - (copilot-next-completion)) |
| 42 | +(defun github-copilot/init-copilot-chat () |
| 43 | + "Initialize the `copilot-chat' package and set up keybindings." |
| 44 | + (use-package copilot-chat |
| 45 | + :hook (git-commit-setup . copilot-chat-insert-commit-message) |
| 46 | + :defer t |
| 47 | + :init |
| 48 | + ;; Provide our transient state in the AI menu |
| 49 | + (spacemacs/declare-prefix "$" "AI") |
| 50 | + (spacemacs/set-leader-keys "$c" 'copilot-chat-transient) |
| 51 | + :config |
| 52 | + ;; Make sure that standard ,, works as confirm in the chat window |
| 53 | + (evil-define-key 'normal copilot-chat-prompt-mode-map ",," #'copilot-chat-prompt-send) |
| 54 | + (evil-define-key 'normal copilot-chat-prompt-mode-map ",a" #'copilot-chat-kill-instance) |
| 55 | + (evil-define-key 'normal copilot-chat-prompt-mode-map ",k" #'copilot-chat-kill-instance) |
48 | 56 |
|
49 | | -(defun github-copilot/previous-completion () |
50 | | - "Move to the previous completion in the Copilot completion menu. |
51 | | -This function will make sure to show the previous completion, |
52 | | -if necessary triggering a `copilot-complete' command beforehand." |
53 | | - (interactive) |
54 | | - (copilot-complete) |
55 | | - (copilot-previous-completion)) |
| 57 | + ;; And don't forget to provide an alternative for holy mode users |
| 58 | + (define-key copilot-chat-prompt-mode-map (kbd "C-c C-c") #'copilot-chat-prompt-send) |
| 59 | + (define-key copilot-chat-prompt-mode-map (kbd "C-c C-a") #'copilot-chat-kill-instance) |
| 60 | + (define-key copilot-chat-prompt-mode-map (kbd "C-c C-k") #'copilot-chat-kill-instance))) |
0 commit comments