最近基于 copilot.el 和 tabnine-capf 改了下 tabnine-capf 插件,现在体验感觉还不错,可以结合 overlay 和 capf 使用,欢迎大佬们体验 ~
项目地址:GitHub - shuxiao9058/tabnine: An overlay version of company-tabnine: https://github.com/TommyX12/company-tabnine
以下是使用的大概配置,首先安装和配置 TabNine 插件,如下,如果需要配置帐号之类的可以执行 tabnine-configuration
命令打开 TabNine Hub 页面配置即可。
(use-package tabnine
:after (on)
:commands (tabnine-start-process)
:hook ((prog-mode vterm-mode) . tabnine-mode)
:straight (tabnine :package "tabnine"
:host github :repo "shuxiao9058/tabnine" )
:diminish "⌬"
:custom
(tabnine-wait 0.5)
(tabnine-minimum-prefix-length 0)
:init
(setq tabnine-executable-args (list "--log-level" "Error" "--no-lsp" "false"))
:hook ((on-first-input . tabnine-start-process)
(kill-emacs . tabnine-kill-process))
:config
(defun +tabnine-disable-predicate()
(or ;; (derived-mode-p 'vterm-mode)
(meow-motion-mode-p)
(meow-normal-mode-p)))
(add-to-list 'tabnine-disable-predicates #'+tabnine-disable-predicate)
:bind
(:map tabnine-mode-map
;; ("C-TAB" . tabnine-accept-completion-by-word)
;; ("C-<tab>" . tabnine-accept-completion-by-word)
("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)
;; ("C-n" . tabnine-next-completion)
;; ("C-p" . tabnine-previous-completion)
))
然后将 tabnine-completion-at-point 添加到 completion-at-point-functions
即可。
(add-to-list 'completion-at-point-functions #'tabnine-completion-at-point)
当然,我的配置链接:
截图简单示例:
overlay 展示补全代码:
corfu 展示补全代码:
4 个赞
当前已支持 TabNine Chat,欢迎体验。。。
牛逼啊。 doom emacs可以这样安装
packages.el
(package! tabnine :recipe (:host github :repo "shuxiao9058/tabnine"))
config.el
(require 'tabnine)
(add-to-list 'prog-mode-hook #'tabnine-mode)
但是使用中有个问题。我用的company补全,
company补全出现的时候会打断 overlay 展示补全。
这个特意这样设计的,如果补全选项行数在两行之内,则认为是普通补全,不通过 overlay 展示,会清空 overlay 。。。
最近支持 TabNine Chat 了,可以体验一把,不过还有一些待优化的,先提交让大佬们体验下,哈哈。。。
rua
9
话说这这个 capf 可以和 eglot 一起用吗,我看 eglot 会重新设置 completion-at-point-function
(when (fboundp #'tabnine-completion-at-point)
(add-hook 'eglot-managed-mode-hook
(defun eglot-capf ()
(remove-hook 'completion-at-point-functions #'eglot-completion-at-point t)
(add-hook 'completion-at-point-functions
(cape-super-capf
#'eglot-completion-at-point
#'tabnine-completion-at-point) nil t))))
1 个赞
我之前使用company + lsp-mode +company-tabnine ,可以达成这种效果
问一下使用corfu + 这个插件如何能达到这种效果
eglot + corfu 就是楼上我回的那段代码,通过 cape-super-capf
把两段后端合并一下,效果如下:
如果用 lsp-mode,就把 eglot 相关的换到对应的 lsp-mode 就行了
可以了,以下是成功的代码感谢!
(when (fboundp #'tabnine-completion-at-point)
(add-hook 'lsp-completion-mode-hook
(defun lsp-capf ()
(remove-hook 'completion-at-point-functions #'lsp-completion-at-point t)
(add-hook 'completion-at-point-functions
(cape-capf-super
#'lsp-completion-at-point
#'tabnine-completion-at-point) nil t))))
1 个赞