Skip to content

Commit a4bce57

Browse files
committed
feat: add typescript-tsx-mode
Will need to keep an eye out for a proper solution. This is just copy-pasta from emacs-typescript/typescript.el#4 (comment)
1 parent 6fa37db commit a4bce57

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

readme.org

+29-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ My [[https://github.com/raxod502/straight.el][straight.el]] based emacs configur
1919
- Bootstrap
2020

2121
#+begin_src elisp :tangle ./early-init.el
22-
;;; core-ui.el -*- lexical-binding: t; -*-
22+
;; -*- lexical-binding: t -*-
2323
(setq package-enable-at-startup nil)
2424

2525
;;
@@ -1022,18 +1022,44 @@ says on the box without much fuss.
10221022
(setq emmet-insert-flash-time 0.001) ; effectively disabling it
10231023
(add-hook 'js-jsx-mode-hook #'(lambda ()
10241024
(setq-local emmet-expand-jsx-className? t)))
1025-
(add-hook 'ts-tsx-mode-hook #'(lambda ()
1025+
(add-hook 'typescript-tsx-mode-hook #'(lambda ()
10261026
(setq-local emmet-expand-jsx-className? t)))
10271027
(add-hook 'web-mode-hook #'(lambda ()
10281028
(setq-local emmet-expand-jsx-className? t))))
10291029

10301030
(use-package typescript-mode
1031-
:mode "\\.tsx?\\'")
1031+
:mode "\\.ts?\\'")
10321032

10331033
(use-package css-mode
10341034
:mode "\\.s?css\\'")
10351035
#+end_src
10361036

1037+
- Setup =typescript-tsx-mode= using code I don't fully understand. Copied from
1038+
[[https://github.com/emacs-typescript/typescript.el/issues/4#issuecomment-873485004][typescript.el#4]]
1039+
1040+
#+begin_src elisp
1041+
(use-package typescript-mode
1042+
:ensure t
1043+
:init
1044+
(define-derived-mode typescript-tsx-mode typescript-mode "tsx")
1045+
:config
1046+
(setq typescript-indent-level 2)
1047+
(add-hook 'typescript-mode #'subword-mode)
1048+
(add-to-list 'auto-mode-alist '("\\.tsx?\\'" . typescript-tsx-mode)))
1049+
1050+
(use-package tree-sitter
1051+
:ensure t
1052+
:hook ((typescript-mode . tree-sitter-hl-mode)
1053+
(typescript-tsx-mode . tree-sitter-hl-mode)))
1054+
1055+
(use-package tree-sitter-langs
1056+
:ensure t
1057+
:after tree-sitter
1058+
:config
1059+
(tree-sitter-require 'tsx)
1060+
(add-to-list 'tree-sitter-major-mode-language-alist '(typescript-tsx-mode . tsx)))
1061+
#+end_src
1062+
10371063
*** Rust
10381064

10391065
#+begin_src elisp

0 commit comments

Comments
 (0)