Skip to content

Commit

Permalink
Some yasnippet loading tweaks
Browse files Browse the repository at this point in the history
- Don't enable yasnippet before setting folders (avoid explicitly
  loading them)
- Require yasnippet manually to get the yas-snippet-dirs value
- Don't include yas--default-user-snippet-dir (this is
  ~/.emacs.d/snippets)
- Allow `auto-completion-private-snippets-directory` to also be a list
  of directories
  • Loading branch information
TheBB authored and syl20bnr committed Jan 7, 2016
1 parent c034aca commit 0a1b6f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions layers/auto-completion/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ layer variables:
as been entered quickly enough. If its value is =nil= then the feature is
disabled.

4. =auto-completion-private-snippets-directory= is a path to your private
snippets directory. If its value is =nil= then the spacemacs default is used.
4. =auto-completion-private-snippets-directory= is a path or list of paths to
your private snippets directory. If its value is =nil= then the spacemacs
default (=~/.emacs.d/private/snippets=) is used.

The default configuration of the layer is:

Expand Down
11 changes: 6 additions & 5 deletions layers/auto-completion/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
(defun spacemacs/load-yasnippet ()
(unless yas-global-mode
(progn
(yas-global-mode 1)
(require 'yasnippet)
(let ((private-yas-dir (if auto-completion-private-snippets-directory
auto-completion-private-snippets-directory
(concat
Expand All @@ -236,12 +236,13 @@
"snippets"
spacemacs--auto-completion-dir)))
(setq yas-snippet-dirs
(append (list private-yas-dir)
(append (if (listp private-yas-dir)
private-yas-dir
(list private-yas-dir))
(when (boundp 'yas-snippet-dirs)
yas-snippet-dirs)
(remove yas--default-user-snippets-dir yas-snippet-dirs))
(list spacemacs-snippets-dir)))
(yas-load-directory spacemacs-snippets-dir t)
(yas-load-directory private-yas-dir t)
(yas-global-mode 1)
(setq yas-wrap-around-region t))))
(yas-minor-mode 1))

Expand Down

0 comments on commit 0a1b6f5

Please sign in to comment.