2015-08-01 14:58:51 +00:00
|
|
|
;;; packages.el --- HTML Layer packages File for Spacemacs
|
2015-01-14 04:12:56 +00:00
|
|
|
;;
|
|
|
|
;; Copyright (c) 2012-2014 Sylvain Benner
|
|
|
|
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq html-packages
|
2014-12-16 03:23:55 +00:00
|
|
|
'(
|
2015-04-09 03:57:22 +00:00
|
|
|
company
|
2015-05-06 19:10:36 +00:00
|
|
|
company-web
|
2015-04-09 03:57:22 +00:00
|
|
|
css-mode
|
2014-12-16 03:23:55 +00:00
|
|
|
emmet-mode
|
2015-01-16 04:45:53 +00:00
|
|
|
evil-matchit
|
2014-12-16 03:23:55 +00:00
|
|
|
flycheck
|
2015-08-10 12:43:29 +00:00
|
|
|
haml-mode
|
2014-12-16 03:23:55 +00:00
|
|
|
helm-css-scss
|
2015-08-10 12:43:29 +00:00
|
|
|
jade-mode
|
2014-12-16 03:23:55 +00:00
|
|
|
less-css-mode
|
2015-05-24 18:06:26 +00:00
|
|
|
rainbow-delimiters
|
2015-03-17 22:15:58 +00:00
|
|
|
sass-mode
|
2015-08-10 12:43:29 +00:00
|
|
|
scss-mode
|
|
|
|
slim-mode
|
2015-09-13 06:53:34 +00:00
|
|
|
smartparens
|
2014-12-16 03:23:55 +00:00
|
|
|
tagedit
|
|
|
|
web-mode
|
2015-02-10 18:39:58 +00:00
|
|
|
yasnippet
|
2015-04-19 03:40:24 +00:00
|
|
|
))
|
2014-12-16 03:23:55 +00:00
|
|
|
|
2015-08-10 12:43:29 +00:00
|
|
|
(when (configuration-layer/layer-usedp 'auto-completion)
|
|
|
|
;;TODO: whenever company-web makes a backend for haml-mode it should be added here. -- @robbyoconnor
|
|
|
|
(defun html/post-init-company ()
|
|
|
|
(spacemacs|add-company-hook css-mode)
|
|
|
|
(spacemacs|add-company-hook jade-mode)
|
|
|
|
(spacemacs|add-company-hook slim-mode)
|
|
|
|
(spacemacs|add-company-hook web-mode))
|
|
|
|
|
|
|
|
(defun html/init-company-web ()
|
|
|
|
(use-package company-web)))
|
|
|
|
|
2015-04-09 03:57:22 +00:00
|
|
|
(defun html/init-css-mode ()
|
|
|
|
(use-package css-mode
|
|
|
|
:defer t
|
|
|
|
:init
|
2015-08-28 06:07:17 +00:00
|
|
|
(progn
|
|
|
|
(push 'company-css company-backends-css-mode)
|
|
|
|
|
2015-10-14 19:32:43 +00:00
|
|
|
;; Mark `css-indent-offset' as safe-local variable
|
|
|
|
(put 'css-indent-offset 'safe-local-variable #'integerp)
|
|
|
|
|
2015-08-28 06:07:17 +00:00
|
|
|
(defun css-expand-statement ()
|
|
|
|
"Expand CSS block"
|
|
|
|
(interactive)
|
|
|
|
(save-excursion
|
|
|
|
(end-of-line)
|
|
|
|
(search-backward "{")
|
|
|
|
(forward-char 1)
|
|
|
|
(while (or (eobp) (not (looking-at "}")))
|
|
|
|
(let ((beg (point)))
|
|
|
|
(newline)
|
|
|
|
(search-forward ";")
|
|
|
|
(indent-region beg (point))
|
|
|
|
))
|
|
|
|
(newline)))
|
|
|
|
|
|
|
|
(defun css-contract-statement ()
|
|
|
|
"Contract CSS block"
|
|
|
|
(interactive)
|
|
|
|
(end-of-line)
|
|
|
|
(search-backward "{")
|
|
|
|
(while (not (looking-at "}"))
|
|
|
|
(join-line -1)))
|
|
|
|
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'css-mode
|
|
|
|
"zc" 'css-contract-statement
|
|
|
|
"zo" 'css-expand-statement))))
|
2015-04-09 03:57:22 +00:00
|
|
|
|
2015-08-10 12:43:29 +00:00
|
|
|
(defun html/init-emmet-mode ()
|
|
|
|
(use-package emmet-mode
|
|
|
|
:defer t
|
2015-08-23 01:47:30 +00:00
|
|
|
:init (spacemacs/add-to-hooks 'emmet-mode '(css-mode-hook
|
|
|
|
html-mode-hook
|
|
|
|
web-mode-hook))
|
2015-08-10 12:43:29 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(evil-define-key 'insert emmet-mode-keymap (kbd "TAB") 'emmet-expand-yas)
|
|
|
|
(evil-define-key 'insert emmet-mode-keymap (kbd "<tab>") 'emmet-expand-yas)
|
|
|
|
(evil-define-key 'emacs emmet-mode-keymap (kbd "TAB") 'emmet-expand-yas)
|
|
|
|
(evil-define-key 'emacs emmet-mode-keymap (kbd "<tab>") 'emmet-expand-yas)
|
2015-09-27 16:21:02 +00:00
|
|
|
(evil-define-key 'hybrid emmet-mode-keymap (kbd "TAB") 'emmet-expand-yas)
|
|
|
|
(evil-define-key 'hybrid emmet-mode-keymap (kbd "<tab>") 'emmet-expand-yas)
|
2015-08-10 12:43:29 +00:00
|
|
|
(spacemacs|hide-lighter emmet-mode))))
|
|
|
|
|
|
|
|
(defun html/post-init-evil-matchit ()
|
2015-08-10 19:40:05 +00:00
|
|
|
(add-hook 'web-mode-hook 'turn-on-evil-matchit-mode))
|
2015-08-10 12:43:29 +00:00
|
|
|
|
|
|
|
(defun html/post-init-flycheck ()
|
2015-08-28 11:02:20 +00:00
|
|
|
(dolist (mode '(haml-mode jade-mode less-mode sass-mode scss-mode slim-mode web-mode))
|
|
|
|
(spacemacs/add-flycheck-hook mode)))
|
2015-08-10 12:43:29 +00:00
|
|
|
|
|
|
|
(defun html/init-haml-mode ()
|
|
|
|
(use-package haml-mode
|
|
|
|
:defer t))
|
|
|
|
|
2014-12-16 03:23:55 +00:00
|
|
|
(defun html/init-helm-css-scss ()
|
|
|
|
(use-package helm-css-scss
|
|
|
|
:defer t
|
|
|
|
:init
|
2015-09-13 06:53:34 +00:00
|
|
|
(dolist (mode '(css-mode scss-mode))
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "gh" 'helm-css-scss))))
|
2014-12-16 03:23:55 +00:00
|
|
|
|
2015-08-10 12:43:29 +00:00
|
|
|
(defun html/init-jade-mode ()
|
|
|
|
(use-package jade-mode
|
|
|
|
:defer t))
|
|
|
|
|
|
|
|
(defun html/init-less-css-mode ()
|
|
|
|
(use-package less-css-mode
|
|
|
|
:defer t
|
|
|
|
:mode ("\\.less\\'" . less-css-mode)))
|
|
|
|
|
|
|
|
(defun html/init-sass-mode ()
|
|
|
|
(use-package sass-mode
|
|
|
|
:defer t
|
|
|
|
:mode ("\\.sass\\'" . sass-mode)))
|
|
|
|
|
|
|
|
(defun html/init-scss-mode ()
|
|
|
|
(use-package scss-mode
|
|
|
|
:defer t
|
|
|
|
:mode ("\\.scss\\'" . scss-mode)))
|
|
|
|
|
|
|
|
(defun html/init-slim-mode ()
|
|
|
|
(use-package slim-mode
|
|
|
|
:defer t))
|
|
|
|
|
2015-09-13 06:53:34 +00:00
|
|
|
(defun html/post-init-smartparens ()
|
2015-09-25 09:01:35 +00:00
|
|
|
(spacemacs/add-to-hooks
|
|
|
|
(if dotspacemacs-smartparens-strict-mode
|
|
|
|
'smartparens-strict-mode
|
|
|
|
'smartparens-mode)
|
|
|
|
'(css-mode-hook scss-mode-hook sass-mode-hook less-css-mode-hook))
|
|
|
|
|
|
|
|
;; Only use smartparens in web-mode
|
2015-11-29 08:17:37 +00:00
|
|
|
(with-eval-after-load 'smartparens
|
|
|
|
(setq web-mode-enable-auto-pairing nil)
|
|
|
|
(sp-local-pair 'web-mode "<% " " %>")
|
|
|
|
(sp-local-pair 'web-mode "{ " " }")
|
|
|
|
(sp-local-pair 'web-mode "<%= " " %>")
|
|
|
|
(sp-local-pair 'web-mode "<%# " " %>")
|
|
|
|
(sp-local-pair 'web-mode "<%$ " " %>")
|
|
|
|
(sp-local-pair 'web-mode "<%@ " " %>")
|
|
|
|
(sp-local-pair 'web-mode "<%: " " %>")
|
|
|
|
(sp-local-pair 'web-mode "{{ " " }}")
|
|
|
|
(sp-local-pair 'web-mode "{% " " %}")
|
|
|
|
(sp-local-pair 'web-mode "{%- " " %}")
|
|
|
|
(sp-local-pair 'web-mode "{# " " #}")))
|
2015-09-13 06:53:34 +00:00
|
|
|
|
2015-08-10 12:43:29 +00:00
|
|
|
(defun html/init-tagedit ()
|
|
|
|
(use-package tagedit
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(tagedit-add-experimental-features)
|
|
|
|
(add-hook 'html-mode-hook (lambda () (tagedit-mode 1)))
|
|
|
|
(spacemacs|diminish tagedit-mode " Ⓣ" " T"))))
|
|
|
|
|
|
|
|
(defun html/post-init-rainbow-delimiters ()
|
2015-08-23 01:47:30 +00:00
|
|
|
(spacemacs/add-to-hooks 'rainbow-delimiters-mode '(haml-mode-hook
|
|
|
|
jade-mode-hook
|
|
|
|
less-css-mode-hook
|
|
|
|
scss-mode-hook
|
|
|
|
slim-mode-hook)))
|
2015-08-10 12:43:29 +00:00
|
|
|
|
2014-12-16 03:23:55 +00:00
|
|
|
(defun html/init-web-mode ()
|
|
|
|
(use-package web-mode
|
|
|
|
:defer t
|
2015-05-06 19:10:36 +00:00
|
|
|
:init
|
2015-10-28 15:23:43 +00:00
|
|
|
(push '(company-web-html company-css) company-backends-web-mode)
|
2015-03-02 20:52:30 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'web-mode
|
|
|
|
"eh" 'web-mode-dom-errors-show
|
|
|
|
"gb" 'web-mode-element-beginning
|
|
|
|
"gc" 'web-mode-element-child
|
|
|
|
"gp" 'web-mode-element-parent
|
|
|
|
"gs" 'web-mode-element-sibling-next
|
|
|
|
"hp" 'web-mode-dom-xpath
|
|
|
|
"rc" 'web-mode-element-clone
|
|
|
|
"rd" 'web-mode-element-vanish
|
|
|
|
"rk" 'web-mode-element-kill
|
|
|
|
"rr" 'web-mode-element-rename
|
|
|
|
"rw" 'web-mode-element-wrap
|
|
|
|
"z" 'web-mode-fold-or-unfold
|
2015-03-02 20:52:30 +00:00
|
|
|
;; TODO element close would be nice but broken with evil.
|
|
|
|
)
|
|
|
|
|
2015-03-07 04:47:22 +00:00
|
|
|
(defvar spacemacs--web-mode-ms-doc-toggle 0
|
|
|
|
"Display a short doc when nil, full doc otherwise.")
|
|
|
|
|
|
|
|
(defun spacemacs//web-mode-ms-doc ()
|
|
|
|
(if (equal 0 spacemacs--web-mode-ms-doc-toggle)
|
|
|
|
"[?] for help"
|
|
|
|
"
|
|
|
|
[?] display this help
|
2015-03-27 10:45:01 +00:00
|
|
|
[k] previous [j] next [K] previous sibling [J] next sibling
|
|
|
|
[h] parent [l] child [c] clone [d] delete [D] kill [r] rename
|
|
|
|
[w] wrap [p] xpath
|
2015-03-07 04:47:22 +00:00
|
|
|
[q] quit"))
|
|
|
|
|
|
|
|
(defun spacemacs//web-mode-ms-toggle-doc ()
|
|
|
|
(interactive)
|
|
|
|
(setq spacemacs--web-mode-ms-doc-toggle
|
|
|
|
(logxor spacemacs--web-mode-ms-doc-toggle 1)))
|
|
|
|
|
2015-03-02 20:52:30 +00:00
|
|
|
(spacemacs|define-micro-state web-mode
|
2015-03-07 04:47:22 +00:00
|
|
|
:doc (spacemacs//web-mode-ms-doc)
|
2015-03-02 20:52:30 +00:00
|
|
|
:persistent t
|
2015-03-07 04:47:22 +00:00
|
|
|
:evil-leader-for-mode (web-mode . "m.")
|
2015-03-02 20:52:30 +00:00
|
|
|
:bindings
|
2015-03-07 04:47:22 +00:00
|
|
|
("<escape>" nil :exit t)
|
|
|
|
("?" spacemacs//web-mode-ms-toggle-doc)
|
|
|
|
("c" web-mode-element-clone)
|
|
|
|
("d" web-mode-element-vanish)
|
2015-03-27 10:45:01 +00:00
|
|
|
("D" web-mode-element-kill)
|
|
|
|
("j" web-mode-element-next)
|
|
|
|
("J" web-mode-element-sibling-next)
|
2015-08-29 07:11:09 +00:00
|
|
|
("gj" web-mode-element-sibling-next)
|
2015-03-27 10:45:01 +00:00
|
|
|
("k" web-mode-element-previous)
|
|
|
|
("K" web-mode-element-sibling-previous)
|
2015-08-29 07:11:09 +00:00
|
|
|
("gk" web-mode-element-sibling-previous)
|
2015-03-27 10:45:01 +00:00
|
|
|
("h" web-mode-element-parent)
|
|
|
|
("l" web-mode-element-child)
|
2015-03-02 20:52:30 +00:00
|
|
|
("p" web-mode-dom-xpath)
|
2015-08-28 22:00:28 +00:00
|
|
|
("r" web-mode-element-rename :exit t)
|
2015-03-07 04:47:22 +00:00
|
|
|
("q" nil :exit t)
|
|
|
|
("w" web-mode-element-wrap)))
|
|
|
|
|
|
|
|
:mode
|
|
|
|
(("\\.phtml\\'" . web-mode)
|
|
|
|
("\\.tpl\\.php\\'" . web-mode)
|
2015-08-18 16:13:32 +00:00
|
|
|
("\\.twig\\'" . web-mode)
|
2015-03-07 04:47:22 +00:00
|
|
|
("\\.html\\'" . web-mode)
|
|
|
|
("\\.htm\\'" . web-mode)
|
|
|
|
("\\.[gj]sp\\'" . web-mode)
|
2015-08-30 11:20:26 +00:00
|
|
|
("\\.as[cp]x?\\'" . web-mode)
|
2015-07-06 14:27:47 +00:00
|
|
|
("\\.eex\\'" . web-mode)
|
2015-03-07 04:47:22 +00:00
|
|
|
("\\.erb\\'" . web-mode)
|
|
|
|
("\\.mustache\\'" . web-mode)
|
|
|
|
("\\.handlebars\\'" . web-mode)
|
|
|
|
("\\.hbs\\'" . web-mode)
|
2015-04-18 21:09:45 +00:00
|
|
|
("\\.eco\\'" . web-mode)
|
2015-05-29 17:00:06 +00:00
|
|
|
("\\.jsx\\'" . web-mode)
|
2015-07-05 20:20:07 +00:00
|
|
|
("\\.ejs\\'" . web-mode)
|
2015-03-07 04:47:22 +00:00
|
|
|
("\\.djhtml\\'" . web-mode))))
|
2014-12-16 03:23:55 +00:00
|
|
|
|
2015-08-10 12:43:29 +00:00
|
|
|
(defun html/post-init-yasnippet ()
|
2015-08-23 01:47:30 +00:00
|
|
|
(spacemacs/add-to-hooks 'spacemacs/load-yasnippet '(css-mode-hook
|
|
|
|
jade-mode
|
|
|
|
slim-mode)))
|