I use the packages Company mode and Yasnippet. When I'm typing in a buffer, I get autocompletion suggestions from Company.

For Yasnippet, I have a directory which contains the snippets. In that directory I have for example, the file foo.yasnippet.

When I'm typing foo in the buffer, and press Tab, I get a popup menu for yasnippets, which I chan choose which snippet (foo or foo-bar) I want to insert. I would like to integrate the yasnippet foo in Company completion. When I type foo, then I would like to see the snippet in Company completion popup.

Is this possible? If so, how could I achieve this? In Vim you have that with Neocomplete and VimSnippets. When I googled around, I found this link with Elisp but I couldn't wrap my head around how to apply it.

Any suggestions?

  • 2
    That elisp is a yasnippet "backend" for company (included with company). You can read about it by typing C-h f company-yasnippet RET
    – nanny
    Commented Mar 31, 2015 at 19:52

1 Answer 1


I have the following snippet in my configuration and it seems like it's exactly what you want:

;; Add yasnippet support for all company backends
;; https://github.com/syl20bnr/spacemacs/pull/179
(defvar company-mode/enable-yas t
  "Enable yasnippet for all backends.")

(defun company-mode/backend-with-yas (backend)
  (if (or (not company-mode/enable-yas) (and (listp backend) (member 'company-yasnippet backend)))
    (append (if (consp backend) backend (list backend))
            '(:with company-yasnippet))))

(setq company-backends (mapcar #'company-mode/backend-with-yas company-backends))

Basically it sets up the yasnippet backend with every other backend you have activated, so you get the proper completion for the corresponding backend as well as your snippets.

  • 5
    I didn't expected to get any answer on this, so Patrick, I'm really grateful for this. Thanks for that!
    – ReneFroger
    Commented Apr 5, 2015 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.