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)))) (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 ;; ;; cape ;;;;;
;; (setq-default company-frontends '(company-preview-frontend)))
(use-package! codeium ;; (use-package! cape)
: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))))
;; if you want multiple completion backends, use cape (https://github.com/minad/cape): ;; ;; (after! company
;; (add-hook 'python-mode-hook ;; ;; (setq-default company-frontends '(company-preview-frontend)))
;; (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!
;; codeium-completion-at-point is autoloaded, but you can ;; (use-package! codeium
;; optionally set a timer, which might speed up things as the ;; :after cape
;; codeium local language server takes ~0.2s to start up ;; :init
;; (add-hook 'emacs-startup-hook ;; ;; use globally
;; (lambda () (run-with-timer 0.1 nil #'codeium-init))) ;; (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 ;; ;; if you want multiple completion backends, use cape (https://github.com/minad/cape):
:config ;; ;; (add-hook 'python-mode-hook
(setq use-dialog-box nil) ;; do not use popup boxes ;; ;; (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 ;; ;; codeium-completion-at-point is autoloaded, but you can
;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") ;; ;; optionally set a timer, which might speed up things as the
(setq codeium/metadata/api_key (with-temp-buffer (insert-file-contents "~/.codeium") ;; ;; codeium local language server takes ~0.2s to start up
(buffer-string))) ;; ;; (add-hook 'emacs-startup-hook
;; ;; (lambda () (run-with-timer 0.1 nil #'codeium-init)))
;; (defalias 'my/codeium-complete ;; ;; :defer t ;; lazy loading, if you want
;; (cape-interactive-capf #'codeium-completion-at-point)) ;; :config
(map! :localleader ;; ;; company conf
:map evil-normal-state-map ;; (setq! company-idle-delay 0.05
"c e" #'my/codeium-complete) ;; 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 use-dialog-box nil) ;; do not use popup boxes
(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! ;; ;; if you don't want to use customize to save the api-key
;; for example, we recommend limiting the string sent to codeium for better performance ;; ;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
(defun my-codeium/document/text () ;; (setq codeium/metadata/api_key (with-temp-buffer (insert-file-contents "~/.codeium")
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max)))) ;; (buffer-string)))
;; if you change the text, you should also change the cursor_offset
;; warning: this is measured by UTF-8 encoded bytes ;; ;; (defalias 'my/codeium-complete
(defun my-codeium/document/cursor_offset () ;; ;; (cape-interactive-capf #'codeium-completion-at-point))
(codeium-utf8-byte-length
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point))))
(setq codeium/document/text 'my-codeium/document/text) ;; (map! :localleader
(setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset)) ;; :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) (package! centaur-tabs)
;; nix ;; nix
(package! nixpkgs-fmt) (package! nixpkgs-fmt)
;; codeium ;; codeium
(package! codeium :recipe (:host github :repo "Exafunction/codeium.el")) (package! codeium :recipe (:host github :repo "Exafunction/codeium.el"))
(package! cape) (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 ;; Doom's packages are pinned to a specific commit and updated from release to
;; release. The `unpin!' macro allows you to unpin single packages... ;; release. The `unpin!' macro allows you to unpin single packages...
;;(unpin! pinned-package) ;;(unpin! pinned-package)

View file

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

View file

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

View file

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