From 1beacc0121ac4a5ea4e603e92351cb7a9fac73ea Mon Sep 17 00:00:00 2001 From: Tristan Druyen Date: Tue, 30 Jan 2024 15:32:51 +0100 Subject: [PATCH] Readd copilot --- ext/doom/config.el | 150 ++++++++++++++++++-------------- ext/doom/packages.el | 7 +- home-mods/audio/default.nix | 1 + home-mods/shell/default.nix | 4 +- systems/nixos-pulse/default.nix | 1 - 5 files changed, 97 insertions(+), 66 deletions(-) diff --git a/ext/doom/config.el b/ext/doom/config.el index 33a771e..9c0ab55 100644 --- a/ext/doom/config.el +++ b/ext/doom/config.el @@ -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 + ("" . 'copilot-clear-overlay) + ("" . 'copilot-previous-completion) + ("" . 'copilot-next-completion) + ("" . 'copilot-accept-completion) + ("TAB" . 'copilot-accept-completion) + ("C-TAB" . 'copilot-accept-completion-by-word) + ("C-" . '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)) +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/ext/doom/packages.el b/ext/doom/packages.el index 519ef32..c7faebd 100644 --- a/ext/doom/packages.el +++ b/ext/doom/packages.el @@ -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) diff --git a/home-mods/audio/default.nix b/home-mods/audio/default.nix index a5bb50e..fb82e96 100644 --- a/home-mods/audio/default.nix +++ b/home-mods/audio/default.nix @@ -11,6 +11,7 @@ }; home.packages = with pkgs.unstable-os; [ + my.spotube spotify ncspot ]; diff --git a/home-mods/shell/default.nix b/home-mods/shell/default.nix index 9823096..e4ab0f5 100644 --- a/home-mods/shell/default.nix +++ b/home-mods/shell/default.nix @@ -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) diff --git a/systems/nixos-pulse/default.nix b/systems/nixos-pulse/default.nix index 9bc97f7..2382648 100644 --- a/systems/nixos-pulse/default.nix +++ b/systems/nixos-pulse/default.nix @@ -161,7 +161,6 @@ environment.systemPackages = with pkgs.unstable-os; [ android-tools android-udev-rules - my.spotube ]; hardware = {