Browse Source

Use web-mode for tsx code

Lily Carpenter 11 months ago
parent
commit
4e258f2958
1 changed files with 16 additions and 4 deletions
  1. 16 4
      packages/typescript.el

+ 16 - 4
packages/typescript.el

@@ -1,5 +1,17 @@
1
+(require 'web-mode)
2
+(defun setup-tide-mode ()
3
+  (interactive)
4
+  (tide-setup)
5
+  (eldoc-mode +1)
6
+  (tide-hl-identifier-mode +1))
1 7
 (use-package tide
2
-  :hook ((typescript-mode . tide-setup)
3
-         (before-save-hook . tide-format-before-save))
4
-  :mode ("\\.tsx\\'" . typescript-mode)
5
-  :init (flycheck-add-next-checker 'typescript-tide 'javascript-eslint 'append))
8
+  :demand t
9
+  :hook ((before-save . tide-format-before-save))
10
+  :mode ("\\.tsx\\'" . web-mode)
11
+  :config (flycheck-add-next-checker 'typescript-tide 'javascript-eslint 'append)
12
+  (flycheck-add-mode 'typescript-tide 'web-mode)
13
+  (add-hook 'web-mode-hook
14
+          (lambda ()
15
+            (when (string-equal "tsx" (file-name-extension buffer-file-name))
16
+              (setup-tide-mode)))))
17
+(setq web-mode-enable-auto-pairing t)