TabNine is the all-language autocompleter. It uses machine learning to provide responsive, reliable, and relevant suggestions.
company-tabnine
provides TabNine completion backend for company-mode. It takes care of TabNine binaries, so installation is easy.
-
Make sure company-mode is installed and configured.
-
Install
company-tabnine
. This package is part of MELPA.-
With use-package
Put the following in your config:
(use-package company-tabnine :ensure t)
-
With
package.el
(built-in)Install the package:
M-x package-install RET company-tabnine RET
Put the following in your config:
(require 'company-tabnine)
-
-
Add
company-tabnine
tocompany-backends
(add-to-list 'company-backends #'company-tabnine)
-
Run
M-x company-tabnine-install-binary
to install the TabNine binary for your system.
Below are some recommended company-mode
configuration that works well with company-tabnine
.
;; Trigger completion immediately.
(setq company-idle-delay 0)
;; Number the candidates (use M-1, M-2 etc to select completions).
(setq company-show-numbers t)
;; Use the tab-and-go frontend.
;; Allows TAB to select and complete at the same time.
(company-tng-configure-default)
(setq company-frontends
'(company-tng-frontend
company-pseudo-tooltip-frontend
company-echo-metadata-frontend))
company-tabnine
should work out of the box.
See M-x customize-group RET company-tabnine RET
for customizations.
company-transformers
or plugins that use it (such ascompany-flx-mode
) can interfere with TabNine's sorting. If this happens, put the following temporary workaround in your config:
;; workaround for company-transformers
(setq company-tabnine--disable-next-transform nil)
(defun my-company--transform-candidates (func &rest args)
(if (not company-tabnine--disable-next-transform)
(apply func args)
(setq company-tabnine--disable-next-transform nil)
(car args)))
(defun my-company-tabnine (func &rest args)
(when (eq (car args) 'candidates)
(setq company-tabnine--disable-next-transform t))
(apply func args))
(advice-add #'company--transform-candidates :around #'my-company--transform-candidates)
(advice-add #'company-tabnine :around #'my-company-tabnine)