branch: elpa/nix-mode
commit d6286ce43b8a52d3d19a7394f186b1a3796354b6
Author: Matthew Bauer <[email protected]>
Commit: Matthew Bauer <[email protected]>
Add pcomplete support to nix.el
---
nix.el | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 98 insertions(+)
diff --git a/nix.el b/nix.el
index 12e9780e1f..02c92a1c16 100644
--- a/nix.el
+++ b/nix.el
@@ -16,6 +16,8 @@
;;; Code:
+(require 'pcomplete)
+
(defgroup nix nil
"Nix-related customizations"
:group 'languages)
@@ -55,6 +57,102 @@
(kill-buffer stdout)
result))
+(defvar nix-commands
+ '("add-to-store"
+ "build"
+ "cat-nar"
+ "cat-store"
+ "copy"
+ "copy-sigs"
+ "dump-path"
+ "edit"
+ "eval"
+ "hash-file"
+ "hash-path"
+ "log"
+ "ls-nar"
+ "ls-store"
+ "optimise-store"
+ "path-info"
+ "ping-store"
+ "repl"
+ "run"
+ "search"
+ "show-config"
+ "show-derivation"
+ "sign-paths"
+ "to-base16"
+ "to-base32"
+ "to-base64"
+ "upgrade-nix"
+ "verify"
+ "why-depends"))
+
+(defvar nix-toplevel-options
+ '("-v"
+ "--verbose"
+ "-h"
+ "--help"
+ "--debug"
+ "--help-config"
+ "--option"
+ "--version"))
+
+(defvar nix-config-options
+ '("allowed-uris"
+ "allow-import-from-derivation"
+ "allow-new-priveleges"
+ "allowed-users"
+ "auto-optimise-store"
+ "builders"
+ "builders-use-substitutes"
+ "build-users-group"
+ "compress-build-log"
+ "connect-timeout"
+ "cores"
+ "extra-sandbox-paths"
+ "extra-substituters"
+ "fallback"
+ "fsync-metadata"
+ "hashed-mirrors"
+ "http-connections"
+ "keep-build-log"
+ "keep-derivations"
+ "keep-env-derivations"
+ "keep-outputs"
+ "max-build-log-size"
+ "max-jobs"
+ "max-silent-time"
+ "netrc-file"
+ "plugin-files"
+ "pre-build-hook"
+ "repeat"
+ "require-sigs"
+ "restrict-eval"
+ "sandbox"
+ "sandbox-dev-shm-size"
+ "sandbox-paths"
+ "secret-key-files"
+ "show-trace"
+ "substitute"
+ "substituters"
+ "system"
+ "timeout"
+ "trusted-public-keys"
+ "trusted-subtituters"
+ "trusted-users"))
+
+;;;###autoload
+(defun pcomplete/nix ()
+ "Completion for the nix command."
+ (while (pcomplete-match "^-" 0)
+ (pcomplete-here nix-toplevel-options)
+ (when (string= "--option"
+ (nth (1- pcomplete-index) pcomplete-args))
+ (pcomplete-here nix-config-options)
+ (pcomplete-here)))
+ (pcomplete-here nix-commands))
+
;;;###autoload
(defun nix-build (&optional attr dir)
"Run nix-build.