From aaaba8a655099ed3dbb90354d01917ac4c5f825d Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Thu, 22 Sep 2022 19:04:30 -0700 Subject: feat(lang/nix): format the buffer on save Delegate the formatting of the buffer to the LSP server. Change-Id: Iabb7b838fba71dffcff5dd272aa5895801d6db3c --- emacs/custom/my-lang-nix.el | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'emacs/custom') diff --git a/emacs/custom/my-lang-nix.el b/emacs/custom/my-lang-nix.el index 9de5c50..7d197e2 100644 --- a/emacs/custom/my-lang-nix.el +++ b/emacs/custom/my-lang-nix.el @@ -14,6 +14,11 @@ :major-modes '(nix-mode) :server-id 'nix)) +(defun my/lsp-nix-install-save-hooks () + "Set up before-save hooks to format buffer." + (add-hook 'before-save-hook #'lsp-format-buffer t t)) + +(add-hook 'nix-mode-hook #'my/lsp-nix-install-save-hooks) (add-hook 'nix-mode-hook #'lsp-deferred) (provide 'my-lang-nix) -- cgit 1.4.1