blob: 7f6857e709f25b4b21c88c1391ba7e3addcfedce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
;;; setup-web-mode.el --- rogs default web mode configuration
;;
;;; Commentary:
;;
;; My default configuration for web mode
;;
;;; Code:
;; Web Mode: Begin
;; JSX configs: http://cha1tanya.com/2015/06/20/configuring-web-mode-with-jsx.html
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.css\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.scss\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.es6\\'" . web-mode))
;; Use web-mode for .jsx files
(add-to-list 'auto-mode-alist '("\\.jsx$" . web-mode))
;; Use web-mode for .hbs files
(add-to-list 'auto-mode-alist '("\\.hbs$" . web-mode))
(setq web-mode-content-types-alist
'(("jsx" . "\\.js[x]?\\'")
("javascript" . "\\.es6?\\'")))
(defadvice web-mode-highlight-part (around tweak-jsx activate)
(if (equal web-mode-content-type "jsx")
(let ((web-mode-enable-part-face nil))
ad-do-it)
ad-do-it))
(defadvice web-mode-highlight-part (around tweak-jsx activate)
(if (equal web-mode-content-type "js")
(let ((web-mode-enable-part-face nil))
ad-do-it)
ad-do-it))
;; Style-Gook
(defun my-web-mode-hook ()
"Hooks for Web mode."
(setq web-mode-enable-auto-pairing t)
(setq web-mode-enable-css-colorization t)
(setq web-mode-enable-auto-expanding t)
(setq web-mode-enable-current-element-highlight t)
(setq web-mode-enable-current-column-highlight t)
)
;; Emmet-Hook
(add-hook 'web-mode-before-auto-complete-hooks
'(lambda ()
(let ((web-mode-cur-language
(web-mode-language-at-pos)))
(if (string= web-mode-cur-language "css")
(setq emmet-use-css-transform t)
(setq emmet-use-css-transform nil)))))
(add-hook 'web-mode-hook 'emmet-mode) ;; Auto-start on any markup modes
(add-hook 'html-mode-hook 'emmet-mode) ;; Auto-start on any markup modes
(add-hook 'web-mode-hook 'my-web-mode-hook)
(add-hook 'web-mode-hook #'emmet-mode)
(setq emmet-preview-default t)
(add-hook 'web-mode-hook 'rainbow-mode)
(provide 'setup-web-mode)
;;; setup-web-mode.el ends here
|