forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-css.el
71 lines (54 loc) · 1.86 KB
/
init-css.el
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
;;; init-css.el --- CSS/Less/SASS/SCSS support -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;;; Colourise CSS colour literals
(when (maybe-require-package 'rainbow-mode)
(dolist (hook '(css-mode-hook html-mode-hook sass-mode-hook))
(add-hook hook 'rainbow-mode)))
;;; Embedding in html
(require-package 'mmm-mode)
(with-eval-after-load 'mmm-vars
(mmm-add-group
'html-css
'((css-cdata
:submode css-mode
:face mmm-code-submode-face
:front "<style[^>]*>[ \t\n]*\\(//\\)?<!\\[CDATA\\[[ \t]*\n?"
:back "[ \t]*\\(//\\)?]]>[ \t\n]*</style>"
:insert ((?c css-tag nil @ "<style type=\"text/css\">"
@ "\n" _ "\n" @ "</style>" @)))
(css
:submode css-mode
:face mmm-code-submode-face
:front "<style[^>]*>[ \t]*\n?"
:back "[ \t]*</style>"
:insert ((?c css-tag nil @ "<style type=\"text/css\">"
@ "\n" _ "\n" @ "</style>" @)))
(css-inline
:submode css-mode
:face mmm-code-submode-face
:front "style=\""
:back "\"")))
(dolist (mode (list 'html-mode 'nxml-mode))
(mmm-add-mode-ext-class mode "\\.r?html\\(\\.erb\\)?\\'" 'html-css)))
;;; SASS and SCSS
(require-package 'sass-mode)
(unless (fboundp 'scss-mode)
;; Prefer the scss-mode built into Emacs
(require-package 'scss-mode))
(setq-default scss-compile-at-save nil)
;;; LESS
(unless (fboundp 'less-css-mode)
;; Prefer the scss-mode built into Emacs
(require-package 'less-css-mode))
(when (maybe-require-package 'skewer-less)
(add-hook 'less-css-mode-hook 'skewer-less-mode))
;; Skewer CSS
(when (maybe-require-package 'skewer-mode)
(add-hook 'css-mode-hook 'skewer-css-mode))
;;; Use eldoc for syntax hints
(require-package 'css-eldoc)
(autoload 'turn-on-css-eldoc "css-eldoc")
(add-hook 'css-mode-hook 'turn-on-css-eldoc)
(provide 'init-css)
;;; init-css.el ends here