mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
58 lines
2.0 KiB
EmacsLisp
58 lines
2.0 KiB
EmacsLisp
;;; siren-copilot.el --- jimeh's Emacs Siren: copilot configuration.
|
|
|
|
;;; Commentary:
|
|
|
|
;; Basic configuration for copilot. Auto completion on steroids.
|
|
|
|
;;; Code:
|
|
|
|
(use-package copilot
|
|
:straight (:host github :repo "zerolfx/copilot.el"
|
|
:files ("dist" "copilot.el"))
|
|
:hook
|
|
(prog-mode . copilot-mode)
|
|
|
|
:general
|
|
("C-<tab>" 'siren-copilot-accept-completion-dwim)
|
|
("<backtab>" 'siren-copilot-accept-completion-dwim)
|
|
("M-F" 'siren-copilot-accept-completion-by-word-dwim)
|
|
("M-E" 'siren-copilot-accept-completion-by-line-dwim)
|
|
(:keymaps 'copilot-completion-map
|
|
"M-N" 'copilot-next-completion
|
|
"M-P" 'copilot-previous-completion)
|
|
|
|
:preface
|
|
(defun siren-copilot-accept-completion-dwim ()
|
|
"Accept the current completion or trigger copilot-compilot."
|
|
(interactive)
|
|
(siren-copilot-complete-or-call 'copilot-accept-completion))
|
|
|
|
(defun siren-copilot-accept-completion-by-word-dwim ()
|
|
"Accept the current completion by word, or trigger copilot-compilot."
|
|
(interactive)
|
|
(siren-copilot-complete-or-call 'copilot-accept-completion-by-word 1))
|
|
|
|
(defun siren-copilot-accept-completion-by-line-dwim ()
|
|
"Accept the current completion by word, or trigger copilot-compilot."
|
|
(interactive)
|
|
(siren-copilot-complete-or-call 'copilot-accept-completion-by-line 1))
|
|
|
|
(defun siren-copilot-complete-or-call (f &rest args)
|
|
"Trigger copilot-complete or call F."
|
|
(if (copilot-current-completion)
|
|
(apply f args)
|
|
(copilot-complete)))
|
|
|
|
:config
|
|
(with-eval-after-load 'company
|
|
;; Use company popup even when there's only one result
|
|
(when (member 'company-preview-if-just-one-frontend company-frontends)
|
|
(delq 'company-preview-if-just-one-frontend company-frontends)
|
|
(setf (nth (position 'company-pseudo-tooltip-unless-just-one-frontend
|
|
company-frontends)
|
|
company-frontends)
|
|
'company-pseudo-tooltip-frontend))))
|
|
|
|
(provide 'siren-copilot)
|
|
;;; siren-copilot.el ends here
|