From 6f20675bff088368ea2d21cce66c804e8365fbdc Mon Sep 17 00:00:00 2001 From: Amolith Date: Wed, 10 Jan 2024 15:32:13 -0500 Subject: [PATCH] replace gh copilot with codeium --- dot_config/doom/config.el.tmpl | 49 +++++++++++++++++++++++++++++----- dot_config/doom/packages.el | 7 +++-- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/dot_config/doom/config.el.tmpl b/dot_config/doom/config.el.tmpl index 1a6fb1ad5c38a72db17369eeda3896f9885e7896..8b3523df9e27feb0e71f8763b6a4e80628051d21 100644 --- a/dot_config/doom/config.el.tmpl +++ b/dot_config/doom/config.el.tmpl @@ -155,13 +155,13 @@ (map! :leader :desc "Push upstream" "g p" #'magit-push-current-to-upstream) -(use-package! copilot - :hook (prog-mode . copilot-mode) - :bind (("C-TAB" . 'copilot-accept-completion-by-word) - ("C-" . 'copilot-accept-completion-by-word) - :map copilot-completion-map - ("" . 'copilot-accept-completion) - ("TAB" . 'copilot-accept-completion))) +;;(use-package! copilot +;; :hook (prog-mode . copilot-mode) +;; :bind (("C-TAB" . 'copilot-accept-completion-by-word) +;; ("C-" . 'copilot-accept-completion-by-word) +;; :map copilot-completion-map +;; ("" . 'copilot-accept-completion) +;; ("TAB" . 'copilot-accept-completion))) (add-hook 'evil-local-mode-hook 'turn-on-undo-tree-mode) @@ -183,3 +183,38 @@ (minibuffer . t) (menu-bar-lines . t) (window-system . x)))) + +(use-package codeium + :init + (add-to-list 'completion-at-point-functions #'codeium-completion-at-point) + (add-hook 'emacs-startup-hook + (lambda () (run-with-timer 0.1 nil #'codeium-init))) + + :config + ;; (setq use-dialog-box nil) ;; do not use popup boxes + + ;; if you don't want to use customize to save the api-key + ;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") + + ;; get codeium status in the modeline + (setq codeium-mode-line-enable + (lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion))))) + (add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t) + ;; alternatively for a more extensive mode-line + ;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t) + + (setq codeium-api-enabled + (lambda (api) + (memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion)))) + + ;; You can overwrite all the codeium configs! + ;; for example, we recommend limiting the string sent to codeium for better performance + (defun my-codeium/document/text () + (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max)))) + ;; if you change the text, you should also change the cursor_offset + ;; warning: this is measured by UTF-8 encoded bytes + (defun my-codeium/document/cursor_offset () + (codeium-utf8-byte-length + (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point)))) + (setq codeium/document/text 'my-codeium/document/text) + (setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset)) diff --git a/dot_config/doom/packages.el b/dot_config/doom/packages.el index 1c6257e2fe88565e2e2e435738edf53c3b630036..4b6dfaa150b91a5b545477e949762a35d7d9c5a7 100644 --- a/dot_config/doom/packages.el +++ b/dot_config/doom/packages.el @@ -45,8 +45,8 @@ (package! org-ref :recipe (:host github :repo "jkitchin/org-ref")) -(package! copilot - :recipe (:host github :repo "zerolfx/copilot.el" :files ("*.el" "dist"))) +;;(package! copilot +;; :recipe (:host github :repo "zerolfx/copilot.el" :files ("*.el" "dist"))) (package! magit-gitflow :recipe (:host github :repo "jtatarik/magit-gitflow")) @@ -55,6 +55,9 @@ (package! evil-collection :recipe (:repo "emacs-evil/evil-collection" :branch "master")) +(package! codeium + :recipe (:host github :repo "Exafunction/codeium.el")) + ;; If the package you are trying to install does not contain a PACKAGENAME.el ;; file, or is located in a subdirectory of the repo, you'll need to specify ;; `:files' in the `:recipe':