emacs: replace company-tabnine with tabnine-capf
Alan Pearce alan@alanpearce.eu
Sun, 23 Apr 2023 22:38:24 +0200
4 files changed, 66 insertions(+), 19 deletions(-)
M user/emacs/init.el → user/emacs/init.el
@@ -516,27 +516,16 @@ (use-package all-the-icons :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 ("<M-tab>" #'company-tabnine-call-other-backends - "<C-tab>" #'company-tabnine-call-other-backends) + :config (setq tabnine-capf-binaries-folder "~/.local/tabnine") + ;; use tabnine-capf-with-disabled + :general ("<M-tab>" #'tabnine-capf-call-other-backends + "<C-tab>" #'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
M user/overlays/extra-packages.nix → 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; + }; + } + ) + ); }
A 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; + }; +}
M user/settings/emacs.nix → user/settings/emacs.nix
@@ -146,6 +146,7 @@ rainbow-mode rainbow-delimiters ripgrep spacemacs-theme + tabnine-capf toml-mode tree-sitter tree-sitter-langs