branch: elpa/nix-mode commit 14c3476ba911c9bd8dc8c537280ed19c102cf4a6 Author: Matthew Bauer <mjbaue...@gmail.com> Commit: Matthew Bauer <mjbaue...@gmail.com>
Custom line indenter. --- nix-mode.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nix-mode.el b/nix-mode.el index 2f1ef95c59..f20697e0fb 100644 --- a/nix-mode.el +++ b/nix-mode.el @@ -151,10 +151,22 @@ If a close brace `}' ends an antiquote, the next character begins a string." (0 (ignore (nix-syntax-propertize-close-brace))))) start end)) +(defun nix-indent-level () + "Get current indent level." + (save-excursion + (beginning-of-line) + (skip-chars-forward "[:space:]") + (let ((baseline (* 2 (nth 0 (syntax-ppss))))) + (cond + ((looking-at "[]})]") (- baseline tab-width)) + ;; ((nix-inside-args) (- baseline tab-width)) + ;; ((nix-inside-let) (+ baseline tab-width)) + (t baseline))))) + (defun nix-indent-line () "Indent current line in a Nix expression." (interactive) - (indent-relative-maybe)) + (indent-line-to (nix-indent-level))) (defvar nix-mode-map