web-mode.el 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. (add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
  2. (add-to-list 'auto-mode-alist '("\\.inc\\'" . web-mode))
  3. (add-to-list 'auto-mode-alist '("\\.tpl\\'" . web-mode))
  4. (add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode))
  5. (add-to-list 'auto-mode-alist '("\\.blade\\'" . web-mode))
  6. (add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode))
  7. (add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
  8. (add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
  9. (add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
  10. (add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
  11. (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
  12. (add-to-list 'auto-mode-alist '("/\\(views\\|html\\|templates\\)/.*\\.php\\'" . web-mode))
  13. (setq web-mode-engines-alist
  14. ' ;(("django" . "\\.html\\'")
  15. ;("php" . "\\.phtml\\'")
  16. ;("php" . "\\.inc\\'")
  17. (("blade" . "\\.blade\\."))
  18. )
  19. (defun web-mode-customizations ()
  20. "Hooks for Web mode."
  21. (setq web-mode-markup-indent-offset 2)
  22. (setq web-mode-css-indent-offset 2)
  23. (setq web-mode-code-indent-offset 2)
  24. (setq web-mode-style-padding 1)
  25. (setq web-mode-script-padding 1)
  26. (setq web-mode-block-padding 0)
  27. (setq web-mode-comment-style 2)
  28. ;; Disabled smartparens in web-mode
  29. (setq smartparens-mode nil)
  30. )
  31. (add-hook 'web-mode-hook 'web-mode-customizations)
  32. (setq web-mode-enable-auto-pairing t)
  33. (setq web-mode-enable-block-face t)
  34. (setq web-mode-enable-part-face t)
  35. (setq web-mode-enable-comment-keywords t)
  36. ;;(setq web-mode-enable-css-colorization t)
  37. (setq web-mode-enable-current-element-highlight t)
  38. (setq web-mode-enable-heredoc-fontification t)
  39. ;;(local-set-key (kbd "RET") 'newline-and-indent)
  40. ;; More tango-y colors
  41. (custom-set-faces
  42. '(web-mode-html-tag-face
  43. ((t (:foreground "#729fcf"))))
  44. '(web-mode-html-tag-bracket-face
  45. ((t (:foreground "#FFE84B"))))
  46. '(web-mode-current-element-highlight-face
  47. ((t (:foreground "#FF8A4B"))))
  48. '(web-mode-current-element-highlight-face
  49. ((t (:background "#000000"
  50. :foreground "#FF8A4B"))))
  51. )
  52. ;; zencoding
  53. (require 'emmet-mode)
  54. (require 'ac-emmet)
  55. (setq emmet-indentation 2)
  56. (add-hook 'web-mode-hook 'emmet-mode)
  57. (add-hook 'css-mode-hook 'emmet-mode)
  58. (add-hook 'web-mode-hook 'ac-emmet-html-setup)
  59. (add-hook 'css-mode-hook 'ac-emmet-css-setup)
  60. (define-key emmet-mode-keymap (kbd "C-j") nil)
  61. (define-key emmet-mode-keymap (kbd "<C-return>") nil)
  62. (define-key emmet-mode-keymap (kbd "C-c e") 'emmet-expand-line)
  63. ;; js2-mode
  64. (require 'js2-mode)
  65. (require 'js2-refactor)
  66. (js2r-add-keybindings-with-prefix "C-c C-m")
  67. (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
  68. (add-to-list 'interpreter-mode-alist '("node" . js2-mode))
  69. (add-hook 'js2-mode-hook 'ac-js2-mode)
  70. (add-hook 'css-mode-hook '(lambda ()
  71. (define-key css-mode-map (kbd "M-i") 'helm-css-scss)))
  72. ;; Autocomplete
  73. (add-hook 'web-mode-hook 'auto-complete-mode)
  74. (add-to-list 'ac-modes 'web-mode)
  75. (add-to-list 'ac-modes 'css-mode)
  76. (provide 'web-mode)