An unofficial TabNine package for Emacs.
- Snippets displayed with overlay, screenshot:
- Classic completions displayed with
completion-at-point-functions
screenshot (corfu)
Add following code to your configuration.
(use-package tabnine
:hook (prog-mode . tabnine-mode)
:straight (:host github :repo "shuxiao9058/tabnine")
:hook (kill-emacs . tabnine-kill-process)
:config
(add-to-list 'completion-at-point-functions #'tabnine-completion-at-point))
-
Install
tabnine
.Clone or download this repository.
Add to your load path:
(add-to-list 'load-path "<path-to-tabnine>") (require 'tabnine)
-
Enable
tabnine-mode
inprog-mode
.(add-to-list 'prog-mode-hook #'tabnine-mode)
-
Run
M-x tabnine-install-binary
to install the TabNine binary for your system. -
Recommend shortcut binding
(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 "TAB") #'tabnine-accept-completion)
(define-key tabnine-completion-map (kbd "<tab>") #'tabnine-accept-completion)
(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)
(define-key tabnine-mode-map (kbd "TAB") #'tabnine-accept-completion)
(define-key tabnine-mode-map (kbd "<tab>") #'tabnine-accept-completion)
- Example of configure with
use-package
.
(use-package tabnine
:after (on)
:commands (tabnine-start-process)
:hook (prog-mode . tabnine-mode)
:straight (tabnine :package "tabnine"
:type git
:host github :repo "shuxiao9058/tabnine")
:diminish "⌬"
:custom
(tabnine-wait 1)
(tabnine-minimum-prefix-length 0)
:hook ((on-first-input . tabnine-start-process)
(kill-emacs . tabnine-kill-process))
:config
(add-to-list 'completion-at-point-functions #'tabnine-completion-at-point)
:bind
(:map tabnine-mode-map
("TAB" . tabnine-accept-completion)
("<tab>" . tabnine-accept-completion))
(:map tabnine-completion-map
("M-f" . tabnine-accept-completion-by-word)
("M-<return>" . tabnine-accept-completion-by-line)
("C-g" . tabnine-clear-overlay)
("M-[" . tabnine-previous-completion)
("M-]" . tabnine-next-completion)))
TabNine can automatically balance parentheses, by removing and adding closing parentheses after the cursor. See the examples here.
Key | action |
---|---|
TAB | tabnine-accept-completion |
Key | action |
---|---|
C-g | tabnine-clear-overlay |
M-f | tabnine-accept-completion-by-word |
M-<return> | tabnine-accept-completion-by-line |
M-[ | tabnine-previous-completion |
M-] | tabnine-next-completion |
- TabNine's local deep learning completion might be enabled by default. It is very CPU-intensive if your device can't handle it. You can check by typing "TabNine::config" in any buffer (your browser should then automatically open to TabNine's config page) and disable Deep TabNine Local (you will lose local deep learning completion).
Thanks to the great work of Tommy Xiang and zerolfx.