Emacs: replace company-tabnine with tabnine
Alan Pearce alan@alanpearce.eu
Sat, 16 Sep 2023 16:37:35 +0200
2 files changed, 21 insertions(+), 7 deletions(-)
M user/emacs/init.el → user/emacs/init.el
@@ -558,12 +558,26 @@ :config (progn (setq company-shell-clean-manpage t) (add-to-list 'company-backends '(company-shell company-shell-env)))) -(use-package company-tabnine +(use-package tabnine :after (company) - :config (setq company-tabnine-binaries-folder "~/.local/tabnine") + :config (progn + (delq 'company-preview-if-just-one-frontend company-frontends) + (setq tabnine-binaries-folder "~/.local/tabnine") + (global-tabnine-mode) + + (define-key tabnine-completion-map (kbd "TAB") #'tabnine-accept-completion) + (define-key tabnine-completion-map (kbd "<tab>") #'tabnine-accept-completion) + + (define-key tabnine-completion-map (kbd "M-f") #'tabnine-accept-completion-by-word) + (define-key tabnine-completion-map (kbd "M-<return>") #'tabnine-accept-completion-by-line) + + (define-key tabnine-completion-map (kbd "C-g") #'tabnine-clear-overlay) + (define-key tabnine-completion-map (kbd "M-[") #'tabnine-next-completion) + (define-key tabnine-completion-map (kbd "M-]") #'tabnine-previous-completion)) :init (progn - (advice-add 'company-tabnine-start-process :around #'quiet) - (add-to-list 'company-backends #'company-tabnine))) + (advice-add 'tabnine-start-process :around #'quiet) + + (add-hook 'kill-emacs-hook #'tabnine-kill-process))) ;;; Documentation
M user/modules/tabnine.nix → user/modules/tabnine.nix
@@ -81,11 +81,11 @@ "tabnine.binary_path" = "${pkgs.tabnine}/bin/TabNine"; }; programs.emacs.extraPackages = epkgs: [ - epkgs.company-tabnine + epkgs.tabnine ]; programs.emacs.extraConfig = '' - (with-eval-after-load 'company-tabnine - (advice-add 'company-tabnine--executable-path :around + (with-eval-after-load 'tabnine + (advice-add 'tabnine--executable-path :around (lambda (original-function &rest args) "${pkgs.tabnine}/bin/TabNine"))) '';