0

yasnippet can be integrated into auto-compltion in spacemacs. I want to show snippets at the top of the auto-completions list. Default is at bottom.

 foo_______________
|foo -> foo snippet|
|foo              a|
|foobar           s|
 ------------------

versus

 foo_______________
|foo              a|
|foobar           s|
|foo -> foo snippet|
 ------------------

... What I tried so far:

auto-complete appears to add ac-source-yasnippet to ac-sources if I tell spacemacs to do so:

(setq-default dotspacemacs-configuration-layers
              '((auto-completion :variables
                                 auto-completion-enable-snippets-in-popup t)))

According to this answer, I can set this manually to change the list order of ac-sources.

    (setq ac-sources '(ac-source-yasnippet
                   ac-source-abbrev
                   ac-source-dictionary
                   ac-source-words-in-same-mode-buffers))

However, this doesn't change anything in my setup. I also tried eval-after-load and add-to-list:

(eval-after-load "auto-complete"
  '(add-to-list 'ac-sources 'ac-source-yasnippet))

If I try to evaluate ac-sources, (C-h v), nothing happens. The variable seems to be nonexistent.

I could also sort the list by usage, as shown in the docs, but that only works with company. This also doesn't change anything in my setup.

(setq-default dotspacemacs-configuration-layers
'((auto-completion :variables
                auto-completion-enable-sort-by-usage t)))

This question actually was asked here before but the only suggested answer is related to ac-config-default which I don't use.

  • for some reason "sort by usage" works now. I can move my snippets to the top by typing them often enough. This is a good workaround, the original question still stands, though. – jollaWellbuur Jul 23 '19 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.