From efcba838eb5fb05f5325d62e236512f9df3a24ce Mon Sep 17 00:00:00 2001 From: David Florness Date: Fri, 17 May 2019 10:26:01 -0600 Subject: [PATCH] Setup web-mode --- lisp/setup-web.el | 48 ++++++++++++----------------------------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/lisp/setup-web.el b/lisp/setup-web.el index 7213095..eb8a690 100644 --- a/lisp/setup-web.el +++ b/lisp/setup-web.el @@ -1,36 +1,12 @@ -(use-package js2-mode - :mode (("\\.m?js\\'" . js2-mode))) - -(defun react-inside-string-q () - "Returns non-nil if inside string, else nil. -Result depends on syntax table's string quote character." - (let ((result (nth 3 (syntax-ppss)))) - result)) - -(defun react-inside-comment-q () - "Returns non-nil if inside comment, else nil. -Result depends on syntax table's comment character." - (let ((result (nth 4 (syntax-ppss)))) - result)) - -(defun react-inside-string-or-comment-q () - "Return non-nil if point is inside string, documentation string or a comment. -If optional argument P is present, test this instead of point." - (or (react-inside-string-q) - (react-inside-comment-q))) - -(use-package rjsx-mode - :defer t - :init - (progn - ;; enable rjsx mode by using magic-mode-alist - (defun +javascript-jsx-file-p () - (and buffer-file-name - (or (equal (file-name-extension buffer-file-name) "js") - (equal (file-name-extension buffer-file-name) "jsx")) - (re-search-forward "\\(^\\s-*import React\\|\\( from \\|require(\\)[\"']react\\)" - magic-mode-regexp-match-limit t) - (progn (goto-char (match-beginning 1)) - (not (react-inside-string-or-comment-q))))) - - (add-to-list 'magic-mode-alist (cons #'+javascript-jsx-file-p 'rjsx-mode)))) +(use-package web-mode + :mode (("\\.phtml\\'" . web-mode) + ("\\.tpl\\.php\\'" . web-mode) + ("\\.[agj]sp\\'" . web-mode) + ("\\.as[cp]x\\'" . web-mode) + ("\\.erb\\'" . web-mode) + ("\\.mustache\\'" . web-mode) + ("\\.djhtml\\'" . web-mode) + ("\\.html?\\'" . web-mode) + ("\\.ts\\'" . web-mode) + ("\\.tsx\\'" . web-mode) + ("\\.jsx\\'" . web-mode))) -- 2.38.4