Readd copilot

This commit is contained in:
Tristan D. 2024-01-30 15:32:51 +01:00
parent dcf285dc7f
commit 1beacc0121
Signed by: tristan
SSH key fingerprint: SHA256:3RU4RLOoM8oAjFU19f1W6t8uouZbA7GWkaSW6rjp1k8
5 changed files with 97 additions and 66 deletions

View file

@ -289,78 +289,102 @@
(centaur-tabs-local-mode))))
)
;; cape ;;;;;
(use-package! cape)
;; Copilot
;; accept completion from copilot and fallback to company
(use-package! copilot
:hook (prog-mode . copilot-mode)
:bind (:map copilot-completion-map
("<backtab>" . 'copilot-clear-overlay)
("<left>" . 'copilot-previous-completion)
("<right>" . 'copilot-next-completion)
("<tab>" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word)))
;; (after! company
;; (setq-default company-frontends '(company-preview-frontend)))
;; ;; cape ;;;;;
(use-package! codeium
:after cape
:init
;; use globally
(add-to-list 'completion-at-point-functions #'codeium-completion-at-point)
;; or on a hook
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local completion-at-point-functions '(codeium-completion-at-point))))
;; (use-package! cape)
;; if you want multiple completion backends, use cape (https://github.com/minad/cape):
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local completion-at-point-functions
;; (list (cape-super-capf #'codeium-completion-at-point #'lsp-completion-at-point)))))
;; an async company-backend is coming soon!
;; ;; (after! company
;; ;; (setq-default company-frontends '(company-preview-frontend)))
;; codeium-completion-at-point is autoloaded, but you can
;; optionally set a timer, which might speed up things as the
;; codeium local language server takes ~0.2s to start up
;; (add-hook 'emacs-startup-hook
;; (lambda () (run-with-timer 0.1 nil #'codeium-init)))
;; (use-package! codeium
;; :after cape
;; :init
;; ;; use globally
;; (add-to-list 'completion-at-point-functions #'codeium-completion-at-point)
;; ;; or on a hook
;; ;; (add-hook 'python-mode-hook
;; ;; (lambda ()
;; ;; (setq-local completion-at-point-functions '(codeium-completion-at-point))))
;; :defer t ;; lazy loading, if you want
:config
(setq use-dialog-box nil) ;; do not use popup boxes
;; ;; if you want multiple completion backends, use cape (https://github.com/minad/cape):
;; ;; (add-hook 'python-mode-hook
;; ;; (lambda ()
;; ;; (setq-local completion-at-point-functions
;; ;; (list (cape-super-capf #'codeium-completion-at-point #'lsp-completion-at-point)))))
;; ;; an async company-backend is coming soon!
;; if you don't want to use customize to save the api-key
;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
(setq codeium/metadata/api_key (with-temp-buffer (insert-file-contents "~/.codeium")
(buffer-string)))
;; ;; codeium-completion-at-point is autoloaded, but you can
;; ;; optionally set a timer, which might speed up things as the
;; ;; codeium local language server takes ~0.2s to start up
;; ;; (add-hook 'emacs-startup-hook
;; ;; (lambda () (run-with-timer 0.1 nil #'codeium-init)))
;; (defalias 'my/codeium-complete
;; (cape-interactive-capf #'codeium-completion-at-point))
;; ;; :defer t ;; lazy loading, if you want
;; :config
(map! :localleader
:map evil-normal-state-map
"c e" #'my/codeium-complete)
;; ;; company conf
;; (setq! company-idle-delay 0.05
;; company-require-match nil
;; company-minimum-prefix-length 0
;; company-frontends '(company-pseudo-tooltip-unless-just-one-frontend company-preview-frontend))
;; 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)
;; ;;;;;;
;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server
(setq codeium-api-enabled
(lambda (api)
(memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion))))
;; you can also set a config for a single buffer like this:
;; (add-hook 'python-mode-hook
;; (lambda ()
;; (setq-local codeium/editor_options/tab_size 4)))
;; (setq use-dialog-box nil) ;; do not use popup boxes
;; 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))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; if you don't want to use customize to save the api-key
;; ;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
;; (setq codeium/metadata/api_key (with-temp-buffer (insert-file-contents "~/.codeium")
;; (buffer-string)))
;; ;; (defalias 'my/codeium-complete
;; ;; (cape-interactive-capf #'codeium-completion-at-point))
;; (map! :localleader
;; :map evil-normal-state-map
;; "c e" #'my/codeium-complete)
;; ;; 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)
;; ;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server
;; (setq codeium-api-enabled
;; (lambda (api)
;; (memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion))))
;; ;; you can also set a config for a single buffer like this:
;; ;; (add-hook 'python-mode-hook
;; ;; (lambda ()
;; ;; (setq-local codeium/editor_options/tab_size 4)))
;; ;; 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))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -46,12 +46,17 @@
(package! centaur-tabs)
;; nix
(package! nixpkgs-fmt)
;; codeium
(package! codeium :recipe (:host github :repo "Exafunction/codeium.el"))
(package! cape)
;; copilot
(package! copilot
:recipe (:host github :repo "zerolfx/copilot.el" :files ("*.el" "dist")))
;; Doom's packages are pinned to a specific commit and updated from release to
;; release. The `unpin!' macro allows you to unpin single packages...
;;(unpin! pinned-package)

View file

@ -11,6 +11,7 @@
};
home.packages = with pkgs.unstable-os; [
my.spotube
spotify
ncspot
];

View file

@ -8,7 +8,7 @@ let
doomemacsSrc = builtins.fetchGit {
url = "https://github.com/doomemacs/doomemacs";
ref = "master";
rev = "03d692f129633e3bf0bd100d91b3ebf3f77db6d1";
rev = "ff33ec8f7a89d168ca533612e2562883c89e029f";
};
neofetchThemesSrc = builtins.fetchGit {
url = "https://github.com/Chick2D/neofetch-themes";
@ -217,6 +217,8 @@ in
nodejs_20
pandoc
python311Full
python311Packages.epc
python311Packages.orjson
rcm
(lib.mkIf config.services.gpg-agent.enable
pinentry-emacs)

View file

@ -161,7 +161,6 @@
environment.systemPackages = with pkgs.unstable-os; [
android-tools
android-udev-rules
my.spotube
];
hardware = {