emacs: start eglot in templ files
Alan Pearce alan@alanpearce.eu
Tue, 18 Jun 2024 20:29:16 +0200
1 files changed, 9 insertions(+), 0 deletions(-)
jump to
M user/emacs/init.el → user/emacs/init.el
@@ -791,6 +791,7 @@ (add-to-list 'project-vc-extra-root-markers "go.mod")) (setq-default go-ts-mode-indent-offset 2) (use-package templ-ts-mode + :gfhook #'eglot-format-before-save-mode :defer t :config (progn (setq-default go-ts-mode-indent-offset 2))) @@ -1093,6 +1094,13 @@ (use-package consult-lsp :commands (consult-lsp-symbols consult-lsp-diagnostics)) +(define-minor-mode eglot-format-before-save-mode + "Whether to ask the LSP to format the buffer before saving" + :init-val nil + (if eglot-format-before-save-mode + (add-hook 'before-save-hook #'eglot-format-buffer nil 'local) + (remove-hook 'before-save-hook #'eglot-format-buffer 'local))) + (use-package eglot :defer 3 :general (:states 'normal :keymaps 'eglot-mode-map @@ -1107,6 +1115,7 @@ lua-mode-hook nim-mode-hook html-mode-hook nix-mode-hook + templ-ts-mode-hook toml-ts-mode-hook haskell-mode-hook) #'eglot-ensure)