init-web.el 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ;;; init-web.el --- Web Configuration File -*- lexical-binding: t -*-
  2. ;;; Commentary:
  3. ;; Some parts copied from prelude-web.el, prelude-js.el and prelude-css.el
  4. ;;; Code:
  5. (use-package web-mode
  6. :custom
  7. (web-mode-enable-auto-pairing nil)
  8. :config
  9. (sp-with-modes '(web-mode)
  10. (sp-local-pair "%" "%"
  11. :unless '(sp-in-string-p)
  12. :post-handlers '(((lambda (&rest _ignored)
  13. (just-one-space)
  14. (save-excursion (insert " ")))
  15. "SPC" "=" "#")))
  16. (sp-local-tag "%" "<% " " %>")
  17. (sp-local-tag "=" "<%= " " %>")
  18. (sp-local-tag "#" "<%# " " %>"))
  19. :init
  20. (add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode))
  21. (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)))
  22. (use-feature css-mode
  23. :custom
  24. (css-indent-offset 2))
  25. (use-package scss-mode
  26. :config
  27. (add-to-list 'auto-mode-alist '("\\.scss\\'" . scss-mode))
  28. :custom
  29. (scss-compile-at-save nil))
  30. (use-package sass-mode)
  31. (use-package tagedit
  32. :diminish
  33. :commands tagedit-mode
  34. :config (tagedit-add-paredit-like-keybindings)
  35. :hook (html-mode . (lambda () (tagedit-mode 1))))
  36. (use-package js2-mode
  37. :init
  38. (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
  39. :custom
  40. (js-indent-level 2)
  41. :hook (js2-mode . (lambda ()
  42. (setq-local electric-layout-rules '((?\; . after)))
  43. (setq mode-name "JS2")
  44. (js2-imenu-extras-mode +1)
  45. (subword-mode +1))))
  46. (use-package mustache-mode
  47. :init
  48. (add-to-list 'auto-mode-alist '("\\.mustache\\'" . mustache-mode)))
  49. (provide 'init-web)
  50. ;;; init-web.el ends here