Search code examples
emacsyasnippet

yasnippet does not load automatically when .html file is loaded


yasnipped has been installed on emacs using elpa/melpa package system.

I can confirm it's in ~/.emacs.d/elpa/yasnippet-20160104.129

When I load an .html file there's no yasnippet menu, as expected, please advise. I did not add anything extra to .emacs


Solution

  • I think your solution might cause you some problems when it comes to updating the elpa yasnippet package. Normally not a good idea to rename the package directories.

    There are a couple of things you probably should try first.

    1. When you have opened an html file, try running

      M-x yas-minor-mode

    If this works, then all you need to do is add a call to yas-minor-mode in the startup hook for html-mode.

    1. Alternatively, you can try executing

      M-x yas-global-mode

    If this works, then all you need to do is put a call to

    (yas-global-mode)
    

    in your init.el file

    1. If this does not work, check the value of the variables yas-snippets-dirs and yas-installed-snippets-dirs. The former is the normal yas variable which lists the directories to search for snippets. The latter is a variable which should contain the path to the top level snippets directory in the elpa package. The former would normally contain something like

      "~/.emacs.d/snippets" yas-installed-snippets-dires

    If the yas-installed-snippets-dirs variable exists and looks correct, you could try putting something like

    (yas/load-directory yas-installed-snippets-dirs)
    

    in your init.el file after you have done the require for yasnippets