Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web-mode #396

Closed
Romanin opened this issue Aug 9, 2013 · 6 comments
Closed

web-mode #396

Romanin opened this issue Aug 9, 2013 · 6 comments

Comments

@Romanin
Copy link

Romanin commented Aug 9, 2013

Hi capitaomorte, by default yasnippet doesn't work with web-mode which is a very convenient mode, much better than the original htm-mode. Can you please do something for that.
Personally I copy and paste the html-mode folder from the snippets directory and rename the copy as web-mode and it just work fine. Perhaps there is a better solution to afford newbies like me to use emacs with web-mode and yasnippet together.

If you can do something for that, that will be great.

@joaotavora
Copy link
Owner

I'm not touching the default snippet collection. You can probably do, but I havent tested

(add-hook 'web-mode-hook #'(lambda () (set (make-local-variable 'yas-extra-modes) 'html-mode)))

its a one liner in your .emacs which you put after you (require 'yasnippet). Then every snippet in html-mode is available whenever your in a web-mode buffer. Drop a line here if it works, if it doesn't, I'll reopen the issue.

@Romanin
Copy link
Author

Romanin commented Aug 9, 2013

Without yas-reload-all it does'nt work. But, after I add yas-reload-all in my .emacs, your solution works fine.

;; yasnippet

(add-to-list 'load-path "~/path-to-yasnippet")
(require 'yasnippet)
(add-hook 'web-mode-hook #'(lambda () (set (make-local-variable 'yas-extra-modes) 'html-mode)))
(yas-global-mode 1)
(yas-reload-all 1)

@joaotavora
Copy link
Owner

That is interesting, thanks!

@Romanin
Copy link
Author

Romanin commented Sep 12, 2013

Since last update (when using the version 20130907.1855 of yasnippet from MELPA) yasnippet doesn't work with web-mode.
If you can do something for that, that will be great.

@eN-Joy
Copy link

eN-Joy commented Jun 17, 2014

What I do is to add a line:
(add-hook 'web-mode-hook #'(lambda () (yas-activate-extra-mode 'html-mode)))

No need to yas-reload-all and html-mode snippets from yasnippet are now visible in web-mode.

@joaotavora
Copy link
Owner

@eN-Joy this is precisely how it should be done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants