[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode a3610b521f 385/500: Use NIX_GET_COMPLETIONS for N
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode a3610b521f 385/500: Use NIX_GET_COMPLETIONS for Nix 3.0 |
Date: |
Sat, 29 Jan 2022 08:27:41 -0500 (EST) |
branch: elpa/nix-mode
commit a3610b521f8fdd7d1ea5b769f33e5baf42646440
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>
Use NIX_GET_COMPLETIONS for Nix 3.0
This supports more parts of Nix than the old pcomplete support.
---
nix.el | 242 +++++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 137 insertions(+), 105 deletions(-)
diff --git a/nix.el b/nix.el
index eddabb79c4..2ed8f84c69 100644
--- a/nix.el
+++ b/nix.el
@@ -67,6 +67,17 @@
(kill-buffer stdout)
result))
+(defvar nix-version)
+(defun nix-version ()
+ "Get the version of Nix"
+ (if nix-version nix-version
+ (let ((stdout (generate-new-buffer "nix eval"))
+ result)
+ (call-process nix-executable nil (list stdout nil) nil "--version")
+ (with-current-buffer stdout (setq result (buffer-string)))
+ (kill-buffer stdout)
+ result)))
+
(defvar nix-commands
'("add-to-store"
"build"
@@ -179,111 +190,132 @@ OPTIONS a list of options to accept."
;;;###autoload
(defun pcomplete/nix ()
"Completion for the nix command."
- (nix--pcomplete-flags nix-toplevel-options)
- (pcomplete-here nix-commands)
- (pcase (nth (1- pcomplete-index) pcomplete-args)
- ("run"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--arg" "--argstr" "-c" "--command"
- "-f" "--file" "-i" "-I" "--include"
- "-k" "--keep" "-u" "--unset"))))
- ("build"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--arg" "--argstr" "--dry-run"
- "-f" "--file" "-I" "--include"
- "--no-link" "-o" "--out-link"))))
- ("add-to-store"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--dry-run" "-n" "--name"))))
- ("copy"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--all" "--arg" "--argstr"
- "-f" "--file" "--from"
- "-I" "--include" "--no-check-sigs"
- "--no-recursive" "-s" "--substitute"
- "--to"))))
- ("copy-sigs"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--all" "--arg" "--argstr"
- "-f" "--file" "-I" "--include"
- "-r" "--recursive" "-s"
"--substituter"))))
- ("dump-path"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--arg" "--argstr"
- "-f" "--file" "-I" "--include"))))
- ("edit"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--arg" "--argstr"
- "-f" "--file" "-I" "--include"))))
- ("eval"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--arg" "--argstr"
- "-f" "--file" "-I" "--include"
- "--json" "--raw"))))
- ("hash-file"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--base16" "--base32"
- "--base64" "--type"))))
- ("hash-path"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--base16" "--base32"
- "--base64" "--type"))))
- ("log"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--arg" "--argstr"
- "-f" "--file" "-I" "--include"
- "--json" "--raw"))))
- ("ls-nar"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("-d" "--directory"
- "--json" "-l" "--long"
- "-R" "--recursive"))))
- ("ls-store"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("-d" "--directory"
- "--json" "-l" "--long"
- "-R" "--recursive"))))
- ("repl"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--arg" "--argstr"
- "-I" "--include"))))
- ("search"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--arg" "--argstr"
- "-f" "--file"
- "-I" "--include"
- "--json" "--no-cache"
- "-u" "--update-cache"))))
- ("show-config"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--json"))))
- ("show-derivation"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--arg" "--argstr"
- "-f" "--file"
- "-I" "--include"
- "-r" "--recursive"))))
- ("sign-paths"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--all" "--arg" "--argstr"
- "-f" "--file" "-I" "--include"
- "-k" "--key-file" "-r" "--recursive"))))
- ("upgrade-nix"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("-p" "--profile"))))
- ("verify"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("--all" "--arg" "--argstr"
- "-f" "--file" "-I" "--include"
- "--no-contents" "--no-trust"
- "-r" "--recursive" "-n" "--sigs-needed"
- "-s" "--substuter"))))
- ("why-depends"
- (nix--pcomplete-flags
- (append nix-toplevel-options '("-a" "--all" "--arg" "--argstr"
- "-f" "--file" "-I" "--include"))))
- (_ (nix--pcomplete-flags nix-toplevel-options)))
- (pcomplete-here (pcomplete-entries)))
+ (if (string-prefix-p "nix (Nix) 3" (nix-version))
+ (let ((stdout (generate-new-buffer "nix-completions"))
+ (process-environment
+ (cons (format "NIX_GET_COMPLETIONS=%s" (1- (length
pcomplete-args)))
+ process-environment))
+ result)
+ (apply 'call-process nix-executable nil (list stdout nil) nil
+ (cdr pcomplete-args))
+ (with-current-buffer stdout (setq result (buffer-string)))
+ (kill-buffer stdout)
+ (let ((lines (split-string result "\n"))
+ completions)
+ (when (string= (nth 1 lines) "filenames")
+ (pcomplete-here (pcomplete-entries nil 'file-exists-p)))
+ (dolist (val (cdr lines))
+ (unless (string= val "")
+ (setq completions (cons val completions))))
+ (dolist (val (cddr pcomplete-args))
+ (pcomplete-here))
+ (pcomplete-here completions)))
+ (progn
+ (nix--pcomplete-flags nix-toplevel-options)
+ (pcomplete-here nix-commands)
+ (pcase (nth (1- pcomplete-index) pcomplete-args)
+ ("run"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr" "-c" "--command"
+ "-f" "--file" "-i" "-I" "--include"
+ "-k" "--keep" "-u" "--unset"))))
+ ("build"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr" "--dry-run"
+ "-f" "--file" "-I" "--include"
+ "--no-link" "-o" "--out-link"))))
+ ("add-to-store"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--dry-run" "-n" "--name"))))
+ ("copy"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "--from"
+ "-I" "--include" "--no-check-sigs"
+ "--no-recursive" "-s" "--substitute"
+ "--to"))))
+ ("copy-sigs"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "-r" "--recursive" "-s"
"--substituter"))))
+ ("dump-path"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"))))
+ ("edit"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"))))
+ ("eval"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "--json" "--raw"))))
+ ("hash-file"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--base16" "--base32"
+ "--base64" "--type"))))
+ ("hash-path"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--base16" "--base32"
+ "--base64" "--type"))))
+ ("log"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "--json" "--raw"))))
+ ("ls-nar"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-d" "--directory"
+ "--json" "-l" "--long"
+ "-R" "--recursive"))))
+ ("ls-store"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-d" "--directory"
+ "--json" "-l" "--long"
+ "-R" "--recursive"))))
+ ("repl"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-I" "--include"))))
+ ("search"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file"
+ "-I" "--include"
+ "--json" "--no-cache"
+ "-u" "--update-cache"))))
+ ("show-config"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--json"))))
+ ("show-derivation"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--arg" "--argstr"
+ "-f" "--file"
+ "-I" "--include"
+ "-r" "--recursive"))))
+ ("sign-paths"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "-k" "--key-file" "-r"
"--recursive"))))
+ ("upgrade-nix"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-p" "--profile"))))
+ ("verify"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"
+ "--no-contents" "--no-trust"
+ "-r" "--recursive" "-n"
"--sigs-needed"
+ "-s" "--substuter"))))
+ ("why-depends"
+ (nix--pcomplete-flags
+ (append nix-toplevel-options '("-a" "--all" "--arg" "--argstr"
+ "-f" "--file" "-I" "--include"))))
+ (_ (nix--pcomplete-flags nix-toplevel-options)))
+ (pcomplete-here (pcomplete-entries)))))
(provide 'nix)
;;; nix.el ends here
- [nongnu] elpa/nix-mode aaef8580c5 351/500: Merge pull request #86 from j-piecuch/smie-tweaks, (continued)
- [nongnu] elpa/nix-mode aaef8580c5 351/500: Merge pull request #86 from j-piecuch/smie-tweaks, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4ffab960ef 345/500: Add AUTHORS.md to gitignore, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ecf005009e 361/500: Remove org-man.el from .texi makefile rule, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 32b013cd62 363/500: Merge pull request #97 from NixOS/fix-94, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 2c19243e2a 364/500: Revert fix for #94, but leave the test., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 55985b326b 366/500: Be smarter about tokenizing symbols., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode a54fc29289 372/500: Always “decompose” in nix-prettify-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c34990e956 371/500: Remove references to /gnu in nix-prettify-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 9043a8d687 369/500: Merge pull request #98 from j-piecuch/94-fix, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode dc298e77b6 375/500: Merge pull request #101 from jgarte/patch-1, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode a3610b521f 385/500: Use NIX_GET_COMPLETIONS for Nix 3.0,
ELPA Syncer <=
- [nongnu] elpa/nix-mode 1dcbf13a1d 402/500: Merge pull request #111 from leungbk/make-run, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c52795de7d 392/500: Add completion-at-point to nix-repl-mode-map, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 75f383899a 395/500: Fixed styles., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0023fc5b10 428/500: Merge pull request #127 from leungbk/nix-drv-regexp, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode bdd3c8a1e5 412/500: Exclude braces from ffap pattern, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode d1ee0e1741 416/500: Use javascript-mode for nix-drv-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0cf1ea1e0e 390/500: Don’t pare nix completions, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 25cd13349f 445/500: Linkify `nix-mode.org` in Readme, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c29b11b647 443/500: Add Package-Requires for dependency on "f", ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e4844f7a71 438/500: Fix nix-system in nix-2.4, ELPA Syncer, 2022/01/29