branch: elpa/nix-mode
commit 6a9cb7e6821b41de2a68181d17501706dce89b44
Author: Leon Isenberg <[email protected]>
Commit: Matthew Bauer <[email protected]>
Add basic REPL via nix-repl
---
nix-mode.el | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/nix-mode.el b/nix-mode.el
index 309a5090af..f934dcc9c1 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -211,6 +211,27 @@ If a close brace `}' ends an antiquote, the next character
begins a string."
(add-to-list 'flycheck-checkers 'nix)
+;;; REPL
+
+(defvar nix-prompt-regexp "nix-repl> ")
+
+(define-derived-mode nix-repl-mode comint-mode "Nix-REPL"
+ "Interactive prompt for Nix."
+ (setq-local comint-prompt-regexp nix-prompt-regexp)
+ (setq-local comint-prompt-read-only t))
+
+(defun nix-repl-show ()
+ "Load the Nix-REPL."
+ (interactive)
+ (pop-to-buffer-same-window
+ (get-buffer-create "*Nix-REPL*"))
+ (unless (comint-check-proc (current-buffer))
+ (nix--make-repl-in-buffer (current-buffer))
+ (nix-repl-mode)))
+
+(defun nix--make-repl-in-buffer (buffer)
+ (make-comint-in-buffer "Nix-REPL" buffer "nix-repl"))
+
;;; Indentation
(defun nix-indent-level-parens ()