参考 https://github.com/TommyX12/company-tabnine

环境说明   made by mengtianwxs

opensuse

spacemacs

melpa官方文档

Installing

To use the MELPA repository, you'll need an Emacs with package.el and TLS support, ie. Emacs 24.1 or greater. To test TLS support you can visit a HTTPS URL, for example with M-x eww RET https://wikipedia.org RET.

Consider using Emacs 26.3 or greater; otherwise you will have to add a kludge to work around a bug described in *Known Issues* below.

Enable installation of packages from MELPA by adding an entry to package-archives after (require 'package) and before the call to package-initialize in your init.el or .emacs file:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired.  See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)

Note that you'll need to run M-x package-refresh-contents or M-x package-list-packages to ensure that Emacs has fetched the MELPA package list before you can install packages with M-x package-install or similar.

To use the stable package repository instead of the default “bleeding-edge” repository, use this instead of "melpa":

(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/") t)

@1 安装company 

M-x package-install RET company RET 

Type M-x company-complete to initiate completion manually. 

@2 安装company-tabnine

M-x package-install RET company-tabnine RET

@3 配置tabnine

(defun dotspacemacs/user-config ()
  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."
(use-package company-tabnine :ensure t)
  
(require 'company-tabnine)
  (add-to-list 'company-backends #'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)
  )

@4  运行 company-tabnine-install-binary  (此前需要重启一下Spe-q-r)



Run M-x company-tabnine-install-binary to install the TabNine binary for your system.

@4.0  把company-tabnine添加到additional列表

dotspacemacs-additional-packages '(
                                      company-tabnine
                                      )

@5 M-x company-mode To on/off

@6 Done

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐