branch: elpa/nix-mode
commit cc23fd6a0e394aeeed603e2bfeb4a5ebc63db660
Author: Matthew Bauer <[email protected]>
Commit: Matthew Bauer <[email protected]>
Default to indent-relative
nix-indent-function is still not ready for default. Too many bugs with
let ... in and parameters. Help wanted! I don’t have enough Emacs
parsing knowledge to do this. Haskell is able to get good indentation
with a similar syntax to Nix, so I know it’s possible.
---
nix-mode.el | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/nix-mode.el b/nix-mode.el
index 1c18eb326c..5b52684064 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -22,6 +22,16 @@
"Nix-related customizations"
:group 'languages)
+(defcustom nix-indent-function 'indent-relative
+ "The function to use to indent.
+
+Valid functions for this are:
+
+- indent-relative
+- nix-indent-line (buggy)"
+ :group 'nix
+ :type 'function)
+
(defgroup nix-mode nil
"Nix mode customizations"
:group 'nix)
@@ -406,6 +416,7 @@ STRING-TYPE type of string based off of Emacs syntax table
types"
(* tab-width (+ (nix-indent-level-parens)
(if (nix-indent-level-is-closing) -1 0)))))
+;;;###autoload
(defun nix-indent-line ()
"Indent current line in a Nix expression."
(interactive)
@@ -513,7 +524,7 @@ The hook `nix-mode-hook' is run when Nix mode is started.
(setq-local parse-sexp-lookup-properties t)
;; Automatic indentation [C-j]
- (setq-local indent-line-function 'nix-indent-line)
+ (setq-local indent-line-function nix-indent-function)
;; Indenting of comments
(setq-local comment-start "# ")