summary refs log tree commit diff
path: root/emacs
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-09-22 19:04:30 -0700
committerFranck Cuny <franck@fcuny.net>2022-09-22 19:04:30 -0700
commitaaaba8a655099ed3dbb90354d01917ac4c5f825d (patch)
treef2b9fa352e97400b90cb7c398ef4e5e6713b59fb /emacs
parentref(completion): add more packages for completion (diff)
downloademacs.d-aaaba8a655099ed3dbb90354d01917ac4c5f825d.tar.gz
feat(lang/nix): format the buffer on save
Delegate the formatting of the buffer to the LSP server.

Change-Id: Iabb7b838fba71dffcff5dd272aa5895801d6db3c
Diffstat (limited to 'emacs')
-rw-r--r--emacs/custom/my-lang-nix.el5
1 files changed, 5 insertions, 0 deletions
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)