Fix #15169, snippets not loading correctly

The auto-completion layer seems not to have been designed/configured correctly.
So that, e.g., when using the julia layer, the `auto-completion/init-yasnippet`
function is called after the `yasnippet-snippets` package has been loaded.
Despite the ``yasnippet-snippets` package containing an `eval-after-load
'yasnippet`, the form within that block is, for some reason, evaluated already
before `auto-completion/init-yasnippet` has been called.

Anyway, what currently happens is that first `(yasnippet-snippets-initialize)`
is evaluated, adding `yasnippet-snippets-dir` to the `yas-snippet-dirs` list.
Then ``auto-completion/init-yasnippet` is called which contains the line `(setq
yas-snippet-dirs nil)`, setting the list to nil again.

As there is quite some logic involved (e.g. the order of evaluation is correct
when the julia layer is not being used), this commit fixes the reported issue by
simply calling `(yasnippet-snippets-initialize)` from
`auto-completion/init-yasnippet` after the yas-snippet-dirs list has been
resetted to nil.

Any cleaner solution is welcome, but I would say this is a 'harmless' very
pragmatic quick fix/solution.
This commit is contained in:
Daniel Nicolai 2021-11-20 16:46:12 +01:00 committed by Maxi Wolff
parent b108f8b319
commit f2755533de
1 changed files with 3 additions and 1 deletions

View File

@ -335,7 +335,9 @@
(when auto-completion-private-snippets-directory
(if (listp auto-completion-private-snippets-directory)
(setq yas-snippet-dirs (append yas-snippet-dirs auto-completion-private-snippets-directory))
(add-to-list 'yas-snippet-dirs auto-completion-private-snippets-directory))))
(add-to-list 'yas-snippet-dirs auto-completion-private-snippets-directory)))
;; initialize again yasnippet-snippets, see PR #15171
(yasnippet-snippets-initialize))
(spacemacs|add-toggle yasnippet
:mode yas-minor-mode
:documentation "Enable snippets."