summaryrefslogtreecommitdiff
path: root/lisp/web.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/web.el')
-rw-r--r--lisp/web.el31
1 files changed, 18 insertions, 13 deletions
diff --git a/lisp/web.el b/lisp/web.el
index 8a21a76..c78d40e 100644
--- a/lisp/web.el
+++ b/lisp/web.el
@@ -21,9 +21,6 @@
)
(add-hook 'web-mode-hook 'my-web-mode-hook)
-
-(require 'eglot)
-
;; JavaScript
(require 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
@@ -36,7 +33,6 @@
(company-quickhelp-mode t)
)
(add-hook 'js2-mode-hook 'my-js2-mode-hook)
-(add-hook 'js2-mode-hook 'eglot-ensure)
(add-hook 'js2-mode-hook #'smartparens-mode)
(push '("\\.js[x]?\\'" . js2-mode) auto-mode-alist)
(define-key js2-mode-map (kbd "M-.") nil)
@@ -58,21 +54,30 @@
;; Typescript
(defun setup-ts-mode()
(interactive)
+ (typescript-indent-level 2)
(company-mode t)
(company-quickhelp-mode t)
)
+(define-derived-mode typescriptreact-mode web-mode "TypescriptReact"
+ "A major mode for tsx.")
(use-package typescript-mode
- :init
- (define-derived-mode typescript-tsx-mode typescript-mode "TSX")
- (add-to-list 'auto-mode-alist `(,(rx ".tsx" eos) . typescript-tsx-mode))
- :config
- :custom
- (typescript-indent-level 2))
-
-
+ :mode (("\\.ts\\'" . typescript-mode)
+ ("\\.tsx\\'" . typescriptreact-mode)))
(add-hook 'typescript-mode-hook #'setup-ts-mode)
-(add-hook 'typescript-mode-hook 'eglot-ensure)
+(add-hook 'typescriptreact-mode-hook #'setup-ts-mode)
+
+(use-package eglot
+ :ensure t
+ :defer 3
+ :hook
+ ((js2-mode
+ typescript-mode
+ typescriptreact-mode) . eglot-ensure))
+ :config
+ (cl-pushnew '((js-mode typescript-mode typescriptreact-mode) . ("typescript-language-server" "--stdio"))
+ eglot-server-programs
+ :test #'equal)
;; Web goodies
(autoload 'json-mode "json-mode"