Skip to content

Instantly share code, notes, and snippets.

@alexagranov
Created April 15, 2016 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexagranov/72157541eb0367c80d79a1d77e71891f to your computer and use it in GitHub Desktop.
Save alexagranov/72157541eb0367c80d79a1d77e71891f to your computer and use it in GitHub Desktop.
;;; package -- Summary:
;;; Commentary:
;;; Hooks for web mode
;;; Code:
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) ;; ERB
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) ;; Plain HTML
(add-to-list 'auto-mode-alist '("\\.js[x]?\\'" . web-mode)) ;; JS + JSX
(add-to-list 'auto-mode-alist '("\\.es6\\'" . web-mode)) ;; ES6
(add-to-list 'auto-mode-alist '("\\.css\\'" . web-mode)) ;; CSS
(add-to-list 'auto-mode-alist '("\\.scss\\'" . web-mode)) ;; SCSS
(add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode)) ;; PHP
(add-to-list 'auto-mode-alist '("\\.blade\\.php\\'" . web-mode)) ;; Blade template
(setq web-mode-content-types-alist
'(("jsx" . "\\.js[x]?\\'")
("javascript" . "\\.es6?\\'")))
(setq web-mode-engines-alist
'(("blade" . "\\.blade\\.")))
(setq web-mode-markup-indent-offset 4)
(setq web-mode-css-indent-offset 4)
(setq web-mode-code-indent-offset 4)
(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))
(setq web-mode-enable-auto-pairing t)
(setq web-mode-enable-css-colorization t)
;; disable jshint since we prefer eslint checking
(with-eval-after-load 'flycheck
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(javascript-jshint)))
;; use eslint with web-mode for jsx files
(flycheck-add-mode 'javascript-eslint 'web-mode))
(require 'react-snippets)
;;; web.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment