From 73ba7b262674ca6c2911e1ab3299570edfeee663 Mon Sep 17 00:00:00 2001 From: larstvei Date: Wed, 21 Jun 2023 13:03:11 +0200 Subject: [PATCH] clean up webdev setup --- init.org | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/init.org b/init.org index b68dfce..9f271ad 100644 --- a/init.org +++ b/init.org @@ -1479,8 +1479,14 @@ #+begin_src emacs-lisp - (setq eglot-events-buffer-size 0) - (add-hook 'eglot-managed-mode-hook (lambda () (eglot-inlay-hints-mode -1))) + (use-package eglot + :defer t + :hook (eglot-managed-mode . (lambda () (eglot-inlay-hints-mode -1))) + :config + (setq eglot-events-buffer-size 0) + (add-to-list 'eglot-server-programs + '(web-mode . ("svelteserver" "--stdio")))) + #+end_src @@ -1882,26 +1888,31 @@ ** Webdev - My webdev setup isn't much, but with eglot, I don't find myself missing - much. It depends on [[https://tree-sitter.github.io/tree-sitter/][Tree-sitter]], which was added in [[https://git.savannah.gnu.org/cgit/emacs.git/tree/etc/NEWS?h=emacs-29#n36][emacs 29.1]]. - - The following is what I use for plain Javascript: + My webdev setup isn't much, but with eglot and Tree-sitter, I don't find + myself missing much. It depends on [[https://tree-sitter.github.io/tree-sitter/][Tree-sitter]], which was added in [[https://git.savannah.gnu.org/cgit/emacs.git/tree/etc/NEWS?h=emacs-29#n36][emacs + 29.1]]. #+begin_src emacs-lisp - (add-to-list 'auto-mode-alist '("\\.jsx?\\'" . js-ts-mode)) - (add-hook 'js-ts-mode-hook 'eglot-ensure) + ;; Major mode for editing JavaScript + (use-package js-ts-mode + :ensure nil + :defer t + :mode "\\.jsx?\\'" + :hook (js-ts-mode . eglot-ensure)) #+end_src - Similarly for Typescript: + Similarly for TypeScript. #+begin_src emacs-lisp - (add-to-list 'auto-mode-alist '("\\.tsx?\\'" . tsx-ts-mode)) - (add-hook 'tsx-ts-mode-hook 'eglot-ensure) - (setq typescript-ts-mode-indent-offset 4) - + ;; tree sitter support for TypeScript + (use-package tsx-ts-mode + :ensure nil + :defer t + :mode "\\.tsx?\\'" + :hook (tsx-ts-mode . eglot-ensure)) #+end_src I am using [[https://svelte.dev][Svelte]] for some projects, where I find [[https://web-mode.org][web-mode]] along with the @@ -1909,13 +1920,12 @@ #+begin_src emacs-lisp - (add-to-list 'auto-mode-alist '("\\.svelte\\'" . web-mode)) - (add-hook 'web-mode-hook 'eglot-ensure) - (with-eval-after-load "web-mode" + (use-package web-mode + :defer t + :mode "\\.svelte\\'" + :hook (web-mode . eglot-ensure) + :config (add-to-list 'web-mode-engines-alist '("svelte" . "\\.svelte\\'"))) - (with-eval-after-load "eglot" - (add-to-list 'eglot-server-programs - '(web-mode . ("svelteserver" "--stdio")))) #+end_src