diff options
Diffstat (limited to 'lisp/web.el')
-rw-r--r-- | lisp/web.el | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/lisp/web.el b/lisp/web.el index 7ec4af3..b29d58f 100644 --- a/lisp/web.el +++ b/lisp/web.el @@ -42,30 +42,27 @@ (add-hook 'js2-mode-hook 'js2-refactor-keybind-setup) -;; Typescript -(defun setup-ts-mode() - (interactive) - (setq typescript-indent-level 2) - (company-mode t) - (company-quickhelp-mode t) - (smartparens-mode 1) -) - -(define-derived-mode typescriptreact-mode web-mode "TypescriptReact" - "A major mode for tsx.") -(use-package typescript-mode - :mode (("\\.ts\\'" . typescript-mode) - ("\\.tsx\\'" . typescriptreact-mode))) -(add-hook 'typescript-mode-hook #'setup-ts-mode) -(add-hook 'typescriptreact-mode-hook #'setup-ts-mode) - ;; Tide for refactoring (defun setup-tide-mode() (tide-setup) (local-set-key [f2] 'tide-rename-symbol) + (tide-hl-identifier-mode +1) + (setq typescript-indent-level 2) + (company-mode t) + (company-quickhelp-mode t) + (smartparens-mode 1) ) (add-hook 'typescript-mode-hook #'setup-tide-mode) +(require 'web-mode) +(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode)) +(add-hook 'web-mode-hook + (lambda () + (when (string-equal "tsx" (file-name-extension buffer-file-name)) + (setup-tide-mode)))) +;; enable typescript-tslint checker +(flycheck-add-mode 'typescript-tslint 'web-mode) + ;; Package management (use-package eglot :custom @@ -73,9 +70,7 @@ :ensure t :defer 3 :hook - ((js2-mode - typescript-mode - typescriptreact-mode) . eglot-ensure)) + ((js2-mode) . eglot-ensure)) :config (cl-pushnew '((js-mode typescript-mode typescriptreact-mode) . ("typescript-language-server" "--stdio")) eglot-server-programs |