diff options
-rw-r--r-- | init.el | 1 | ||||
-rw-r--r-- | lisp/json.el | 5 | ||||
-rw-r--r-- | lisp/web.el | 32 |
3 files changed, 19 insertions, 19 deletions
@@ -50,7 +50,6 @@ (require 'text) (require 'org-custom) (require 'web) -(require 'json) (require 'markdown) (require 'lisp) (require 'json) diff --git a/lisp/json.el b/lisp/json.el index d1093cf..786aa4d 100644 --- a/lisp/json.el +++ b/lisp/json.el @@ -2,13 +2,10 @@ ;;; Code: (add-to-list 'auto-mode-alist '(".eslintrc'" . json-mode)) -(require 'flycheck) -(flycheck-add-mode 'json-jslint 'json-mode) - (defun my-json-mode-hook () "Turn off eglot in JSON mode." - (require 'eglot) (flymake-mode 0) + (flycheck-mode 0) ) (add-hook 'json-mode-hook 'my-json-mode-hook) diff --git a/lisp/web.el b/lisp/web.el index 77c6ef9..3372792 100644 --- a/lisp/web.el +++ b/lisp/web.el @@ -19,8 +19,6 @@ ) (my-web-mode-colors) ) -(add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode)) -(add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode)) (setq-default js-indent-level 2) (require 'flycheck) @@ -35,6 +33,18 @@ (add-hook 'js-mode-hook 'flycheck-mode) (add-hook 'typescript-mode-hook 'flycheck-mode) +;; TSX +(use-package tree-sitter-langs + :config + (tree-sitter-require 'tsx) + (add-to-list 'tree-sitter-major-mode-language-alist '(typescript-tsx-mode . tsx)) + ) + +(define-derived-mode typescript-tsx-mode web-mode "TypeScript[tsx]") +(add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-tsx-mode)) +(flycheck-add-mode 'javascript-eslint 'typescript-tsx-mode) +(add-hook 'typescript-tsx-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 () @@ -48,21 +58,15 @@ (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)) - ) - -(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) +(defun js-eglot-ensure() + "Ensure eglot mode, unless we are in json mode" + (when (string= (file-name-extension buffer-file-name) "js") + (eglot-ensure)) + ) +(add-hook 'js-mode-hook 'js-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"))) |