如何使用自动完成功能完成 yasnippets [英] How to get completion for yasnippets using auto-complete
问题描述
我正在使用 autocomplete-1.4.0 和 yasnippet-0.8.1,在我的 .emacs 文件中按以下顺序和配置.
I am using autocomplete-1.4.0 and yasnippet-0.8.1 with the following order and configuration in my .emacs file.
; === auto-complete ===
(require 'auto-complete)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(require 'auto-complete-config)
(ac-config-default)
;; === yasnippet ===
(require 'yasnippet)
(yas-global-mode t)
(setq yas-snippet-dirs
'("~/.emacs.d/snippets/my-snippets"
"~/.emacs.d/snippets/yasnippet-snippets"
))
但是,对于任何现有代码段或我创建的任何新代码段,我都没有收到自动完成提示.如果我在这里做错了,有人可以帮忙吗?
However, I get no prompts from autocomplete for any of the existing snippets or for any of the new snippets that I create. Can someone help if I am doing something wrong here?
推荐答案
您应该添加 yasnippet ac-source.我的 init 文件中有这个:
You should add the yasnippet ac-source. I have this in my init files:
(defun add-yasnippet-ac-sources ()
(add-to-list 'ac-sources 'ac-source-yasnippet))
然后对于我想要启用 yasnippet 源的每种模式,我将 add-yasnippet-ac-sources
添加到该模式挂钩:
Then for every mode where I want the yasnippet source enabled, I add add-yasnippet-ac-sources
to that mode hook:
(add-hook 'ruby-mode-hook 'add-yasnippet-ac-sources)
这篇关于如何使用自动完成功能完成 yasnippets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!