From b5593641a4078a57a5692034149510b8dca12058 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 18 Jul 2025 17:16:37 +0200 Subject: [PATCH] Add support for TypeScript and TSX --- emacs/emacs.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/emacs/emacs.el b/emacs/emacs.el index 370ce9b..d372028 100644 --- a/emacs/emacs.el +++ b/emacs/emacs.el @@ -107,6 +107,21 @@ (setq auto-mode-alist (append '(("\\.pl\\'" . prolog-mode)) auto-mode-alist)) +;; for typescript and tsx, use treesit-install-language-grammar to enable the built-in Emacs modes; interactive install is fine, see https://www.masteringemacs.org/article/how-to-get-started-tree-sitter +(add-hook 'tsx-ts-mode-hook 'eglot-ensure) +(add-hook 'typescript-ts-mode-hook 'eglot-ensure) + +(with-eval-after-load 'eglot + (add-to-list 'eglot-server-programs + '(tsx-ts-mode . ("npx" "typescript-language-server" "--stdio")))) + +(with-eval-after-load 'eglot + (add-to-list 'eglot-server-programs + '(typescript-ts-mode . ("npx" "typescript-language-server" "--stdio")))) + +(add-to-list 'auto-mode-alist '("\\.ts" . typescript-ts-mode)) +(add-to-list 'auto-mode-alist '("\\.tsx" . tsx-ts-mode)) + (use-package sql-indent :ensure t :config -- 2.47.3