1

I have configured yasnippet and auto-complete bindings so it won't collide, auto complete uses <tab> and yasnippet uses <backtab>:

(add-to-list 'load-path
         "~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(setq yas-snippet-dirs
      '("~/.emacs.d/snippets/snippets"
        "~/.emacs.d/snippets/yasmate/snippets" 
        ))
(yas-global-mode 1)


;; Remove Yasnippet's default tab key binding
(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
;; Set Yasnippet's key binding to shift+tab
(define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)

I also added yasnippet source like this to the ac-sources as recommended in this question.

(defun add-yasnippet-ac-sources ()
  (add-to-list 'ac-sources 'ac-source-yasnippet))
(add-hook 'web-mode-hook 'add-yasnippet-ac-sources)

I created two yasnippets one with the key lorem_dummy and the other with the key lorem_image, one of the examples:

# -*- mode: snippet; require-final-newline: nil -*-
# name: lorem_image
# key: lorem_image
# binding: direct-keybinding
# --
<img src="http://lorempixel.com/${1:width}/${2:height}/${3:$$(yas-choose-value '("abstract" "city" "animals" "food" "people" "transport" "business" "sports" "technics"))}/${4:text}" alt="$3">

So, the problem is that with this init.el AC it simply doesn't works with yasnippet. The autocomplete won't popup with the snippets. If you want to watch exactly what its going on you can watch this video:

video with update and comments

  • 1
    I haven't finally been able to make it work. I get rid of auto-complete package and installed company mode, worked perfectly with all my yasnippets after adding this code on my init.el -- link – Fabman Jun 7 '15 at 12:09
  • i am also unable to make it work, auto-complete-mode has some problems with other packages. other minor modes i have not tried but i have installed company, so let us see if it works. about auto complete mode, if you find any solutions please post here. – Nullx002 Jun 7 '15 at 18:03
  • Company-mode works flawlessly, it took me less than five minutes to configure the default key binding and make it work perfectly with web-mode, yasnippet, emmet and my custom key bindings. If I got time I'll try to make auto complete work just for the shake of it, because right now everything works great. – Fabman Jun 7 '15 at 18:07

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.