本文介绍了如何使用自动完成来完成yasnippets的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.emacs文件中使用autocomplete-1.4.0和yasnippet-0.8.1与以下顺序和配置。

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 03:17