From db728f16997c045162041920e359666dc413ea00 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 23 Apr 2023 22:38:24 +0200 Subject: emacs: replace company-tabnine with tabnine-capf --- user/emacs/init.el | 27 +++++++---------------- user/overlays/extra-packages.nix | 10 +++++++++ user/packages/tabnine-capf.nix | 47 ++++++++++++++++++++++++++++++++++++++++ user/settings/emacs.nix | 1 + 4 files changed, 66 insertions(+), 19 deletions(-) create mode 100644 user/packages/tabnine-capf.nix (limited to 'user') diff --git a/user/emacs/init.el b/user/emacs/init.el index d75b2025..480c411b 100644 --- a/user/emacs/init.el +++ b/user/emacs/init.el @@ -516,27 +516,16 @@ _p_rev _u_pper _=_: upper/lower _r_esolve :defer t :config (setq all-the-icons-color-icons nil)) -(defmacro company-set-secondary-backend-for-mode (mode backend) - (let ((hook-fn-name (intern (concat "ap/set-local-backend-" (symbol-name mode))))) - `(progn - (defun ,hook-fn-name () - (make-local-variable 'company-backends) - (setq company-backends (append - (list - 'company-tabnine - ,backend) - (copy-tree (remq 'company-tabnine company-backends))))) - (add-hook ',(derived-mode-hook-name mode) #',hook-fn-name)))) - -(use-package company-tabnine - :commands (company-tabnine) +(use-package tabnine-capf + :commands (tabnine-completion-at-point) :after (company) - :config (setq company-tabnine-binaries-folder "~/.local/tabnine") - :general ("" #'company-tabnine-call-other-backends - "" #'company-tabnine-call-other-backends) + :config (setq tabnine-capf-binaries-folder "~/.local/tabnine") + ;; use tabnine-capf-with-disabled + :general ("" #'tabnine-capf-call-other-backends + "" #'tabnine-capf-call-other-backends) :init (progn - (advice-add 'company-tabnine-start-process :around #'quiet) - (add-to-list 'company-backends #'company-tabnine))) + (advice-add 'tabnine-capf-start-process :around #'quiet) + (add-to-list 'company-backends #'tabnine-completion-at-point))) ;;; Documentation diff --git a/user/overlays/extra-packages.nix b/user/overlays/extra-packages.nix index 7566548c..67867830 100644 --- a/user/overlays/extra-packages.nix +++ b/user/overlays/extra-packages.nix @@ -1,3 +1,13 @@ self: super: { lumen = super.callPackage ../packages/lumen { }; + emacsPackagesFor = emacs: ( + (super.emacsPackagesFor emacs).overrideScope' ( + eself: esuper: + esuper // { + tabnine-capf = super.callPackage ../packages/tabnine-capf.nix { + inherit eself; + }; + } + ) + ); } diff --git a/user/packages/tabnine-capf.nix b/user/packages/tabnine-capf.nix new file mode 100644 index 00000000..94e730ea --- /dev/null +++ b/user/packages/tabnine-capf.nix @@ -0,0 +1,47 @@ +{ eself +, fetchFromGitHub +, emacs +, gcc +, lib +, writeText +, unstableGitUpdater +, ... +}: +let + rev = "a55cefee20ea94747b12068a1d4b64b0decf37eb"; +in +eself.trivialBuild { + ename = "tabnine-capf"; + pname = "tabnine-capf"; + version = "0.0.1+unstable=2023-04-23"; + + src = fetchFromGitHub { + owner = "50ways2sayhard"; + repo = "tabnine-capf"; + inherit rev; + sha256 = "14n5xklm9cpkn04crvx7mlykk48w2j2w5vcf6ipfj84dhpiyzh0j"; + }; + + packageRequires = with eself; [ dash s ]; + + buildInputs = [ emacs gcc ]; + + buildPhase = '' + runHook preBuild + emacs -L . --batch --funcall batch-byte-compile *.el + runHook postBuild + ''; + + recipe = writeText "recipe" '' + (tabnine-capf :repo "50ways2sayhard/tabnine-capf" :fetcher github) + ''; + + passthru.updateScript = unstableGitUpdater { }; + + meta = with lib; { + description = "A capf version of company-tabnine"; + homepage = "https://github.com/50ways2sayhard/tabnine-capf"; + license = licenses.mit; + inherit (emacs.meta) platforms; + }; +} diff --git a/user/settings/emacs.nix b/user/settings/emacs.nix index 9c9f9660..5f8116be 100644 --- a/user/settings/emacs.nix +++ b/user/settings/emacs.nix @@ -146,6 +146,7 @@ in rainbow-delimiters ripgrep spacemacs-theme + tabnine-capf toml-mode tree-sitter tree-sitter-langs -- cgit 1.4.1