将自定义yasnippet目录添加到`Spacemacs`

时间:2017-10-11 19:24:07

标签: emacs spacemacs yasnippet

很抱歉这是一个非常新的问题,但我只想在yasnippets中为spacemacs配置一个单独的目录。我根本不熟悉emacs lisp。所以它说我可以把目录放在

(setq-default dotspacemacs-configuration-layers '(
(auto-completion :variables
auto-completion-return-key-behavior 'complete
auto-completion-tab-key-behavior 'cycle
auto-completion-complete-with-key-sequence nil
auto-completion-complete-with-key-sequence-delay 0.1
auto-completion-private-snippets-directory nil)
))

所以我必须设置auto-completion-private-snippets-directory,但我不知道如何配置自定义目录,如"〜/ Dropbox / snippets"。我尝试使用添加的目录下面的代码,但它无法正常工作。

dotspacemacs-configuration-layers '(
...
auto-completion-private-snippets-directory "~/Dropbox/snippets")
))

我不确定是否需要尝试将新目录推送到变量等等。任何建议。

1 个答案:

答案 0 :(得分:2)

我想出了如何做到这一点。基本上只需要将目录附加到yas-snippet-dirs变量。然后将这些附加目录添加到yasnippet收集片段的目录列表中。

;; Snippet configuration
(setq-default dotspacemacs-configuration-layers '(
  (auto-completion :variables
                   auto-completion-return-key-behavior 'complete
                   auto-completion-tab-key-behavior 'cycle
                   auto-completion-complete-with-key-sequence nil
                   auto-completion-complete-with-key-sequence-delay 0.1
           auto-completion-enable-snippets-in-popup t
           auto-completion-enable-sort-by-usage t
           auto-completion-enable-help-tooltip t
                   auto-completion-private-snippets-directory nil)
                   ))

;; add extra snippet directories
(setq yas-snippet-dirs (append yas-snippet-dirs
                               '("/home/<username>/Dropbox/.../snippets")))

(setq yas-snippet-dirs (append yas-snippet-dirs
                               '("/home/<username>/Dropbox/.../more_snippets")))