Fall back to typescript-mode for *.tsx #2252

This commit is contained in:
Henrik Lissner 2019-12-26 14:55:43 -05:00
parent a488c308bb
commit 5c45a9eff9
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 13 additions and 1 deletions

View file

@ -94,7 +94,16 @@
(if (= n 1) (rjsx-maybe-reparse))))
(after! typescript-mode
(use-package! typescript-mode
:defer t
:init
;; REVIEW Fix #2252. This is overwritten if the :lang web module is enabled.
;; We associate TSX files with `web-mode' by default instead because
;; `typescript-mode' does not officially support JSX/TSX. See
;; https://github.com/emacs-typescript/typescript.el/issues/4
(unless (featurep! :lang web)
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-mode)))
:config
(add-hook 'typescript-mode-hook #'rainbow-delimiters-mode)
(setq-hook! 'typescript-mode-hook
comment-line-break-function #'js2-line-break)

View file

@ -1,6 +1,9 @@
;;; lang/web/+html.el -*- lexical-binding: t; -*-
(use-package! web-mode
;; REVIEW We associate TSX files with `web-mode' because `typescript-mode'
;; does not officially support JSX/TSX. See
;; https://github.com/emacs-typescript/typescript.el/issues/4
:mode "\\.\\(?:as\\(?:[cp]x\\)\\|blade\\.php\\|erb\\|hbs\\|j\\(?:inja\\|sp\\)\\|mustache\\|p?html?\\|svelte\\|t\\(?:pl\\.php\\|sx\\|wig\\)\\|vue\\)\\'"
:mode "wp-content/themes/.+/.+\\.php\\'"
:mode "templates/.+\\.php\\'"