summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorMatthew Kosarek <matthew.kosarek@vention.cc>2023-01-04 13:29:04 -0500
committerMatthew Kosarek <matthew.kosarek@vention.cc>2023-01-04 13:29:04 -0500
commitf746700d649f94ea5f62e7de36a1cc37e55d0066 (patch)
treed4397d01282cc05594dd44a8c26be12cb1a15b13 /lisp
parenta5ea55766f7c09f9d105239c547029cf8c7405ad (diff)
Improving tsx mode a little bit more for spacing issues
Diffstat (limited to 'lisp')
-rw-r--r--lisp/web.el38
1 files changed, 15 insertions, 23 deletions
diff --git a/lisp/web.el b/lisp/web.el
index c999e45..77c6ef9 100644
--- a/lisp/web.el
+++ b/lisp/web.el
@@ -23,27 +23,6 @@
(add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode))
(setq-default js-indent-level 2)
-;; JavaScript
-(add-to-list 'auto-mode-alist '("\\.js\\'" . javascript-mode))
-(push '("\\.js[x]?\\'" . javascript-mode) auto-mode-alist)
-
-;; TypeScript
-(use-package tree-sitter-langs
- :config
- (tree-sitter-require 'tsx)
- (add-to-list 'tree-sitter-major-mode-language-alist '(typescript-tsx-mode . tsx))
- )
-(use-package typescript-mode
- :mode "\.ts\'"
- :config (setq typescript-indent-level 2)
- :init
- (define-derived-mode typescript-tsx-mode typescript-mode "TypeScript[tsx]")
- (add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-tsx-mode))
- )
-
-
-
-
(require 'flycheck)
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
@@ -55,6 +34,9 @@
(flycheck-add-mode 'typescript-tslint 'typescript-mode)
(add-hook 'js-mode-hook 'flycheck-mode)
(add-hook 'typescript-mode-hook 'flycheck-mode)
+
+; use local eslint from node_modules before global
+; http://emacs.stackexchange.com/questions/21205/flycheck-with-file-relative-eslint-executable
(defun my-use-eslint-from-node-modules ()
"Use eslint from local node_modules instead of globally."
(let* ((root (locate-dominating-file
@@ -66,16 +48,26 @@
(when (and eslint (file-executable-p eslint))
(setq-local flycheck-javascript-eslint-executable eslint))))
(add-hook 'flycheck-mode-hook #'my-use-eslint-from-node-modules)
+;; TSX
+(use-package tree-sitter-langs
+ :config
+ (tree-sitter-require 'tsx)
+ (add-to-list 'tree-sitter-major-mode-language-alist '(typescript-tsx-mode . tsx))
+ )
-; use local eslint from node_modules before global
-; http://emacs.stackexchange.com/questions/21205/flycheck-with-file-relative-eslint-executable
+(define-derived-mode typescript-tsx-mode web-mode "TypeScript[tsx]")
+(add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-tsx-mode))
+(flycheck-add-mode 'typescript-tslint 'typescript-tsx-mode)
+(add-hook 'typescript-tsx-mode 'flycheck-mode)
;; Package management
(require 'eglot)
(add-hook 'js-mode-hook 'eglot-ensure)
(add-hook 'typescript-mode-hook 'eglot-ensure)
+(add-hook 'typescript-tsx-mode-hook 'eglot-ensure)
(add-to-list 'eglot-server-programs '(js-mode . ("typescript-language-server" "--stdio")))
(add-to-list 'eglot-server-programs '(typescript-mode . ("typescript-language-server" "--stdio")))
+(add-to-list 'eglot-server-programs '(typescript-tsx-mode . ("typescript-language-server" "--stdio")))
;; Ignore certain directories in projectile
(require 'projectile)