From 39419dee17d81fb326aa392cb493839e3d2cb14a Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Mon, 16 Jul 2018 15:49:11 +0200 Subject: [PATCH 1/9] Added company backend for nixos-options --- modules/lang/nix/config.el | 7 +++++++ modules/lang/nix/packages.el | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 modules/lang/nix/config.el diff --git a/modules/lang/nix/config.el b/modules/lang/nix/config.el new file mode 100644 index 000000000..fc69d6727 --- /dev/null +++ b/modules/lang/nix/config.el @@ -0,0 +1,7 @@ +;;; config.el --- description -*- lexical-binding: t; -*- + +(def-package! company-nixos-options + :when (featurep! :completion company) + :after nix-mode + :config + (set-company-backend! 'nix-mode 'company-nixos-options)) diff --git a/modules/lang/nix/packages.el b/modules/lang/nix/packages.el index 7cbed49e6..0049acfcb 100644 --- a/modules/lang/nix/packages.el +++ b/modules/lang/nix/packages.el @@ -2,3 +2,6 @@ ;;; lang/nix/packages.el (package! nix-mode) + +(when (featurep! :completion company) + (package! company-nixos-options)) From d3c24e51f18cdfc5497a3ca46885344f582c3a82 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Mon, 16 Jul 2018 17:09:28 +0200 Subject: [PATCH 2/9] Add support for nix-update --- modules/lang/nix/config.el | 4 ++++ modules/lang/nix/packages.el | 1 + 2 files changed, 5 insertions(+) diff --git a/modules/lang/nix/config.el b/modules/lang/nix/config.el index fc69d6727..060a04e38 100644 --- a/modules/lang/nix/config.el +++ b/modules/lang/nix/config.el @@ -5,3 +5,7 @@ :after nix-mode :config (set-company-backend! 'nix-mode 'company-nixos-options)) + +(def-package! nix-update + :after nix-mode + :commands (nix-update-fetch)) diff --git a/modules/lang/nix/packages.el b/modules/lang/nix/packages.el index 0049acfcb..6cd491c8b 100644 --- a/modules/lang/nix/packages.el +++ b/modules/lang/nix/packages.el @@ -2,6 +2,7 @@ ;;; lang/nix/packages.el (package! nix-mode) +(package! nix-update :recipe (:fetcher github :repo "jwiegley/nix-update-el")) (when (featurep! :completion company) (package! company-nixos-options)) From bdbe942fb9b039bb3e29af556d898d8f7dea88e3 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Mon, 16 Jul 2018 17:10:18 +0200 Subject: [PATCH 3/9] Make available nix-repl-show --- modules/lang/nix/config.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/lang/nix/config.el b/modules/lang/nix/config.el index 060a04e38..3cb5d4078 100644 --- a/modules/lang/nix/config.el +++ b/modules/lang/nix/config.el @@ -9,3 +9,7 @@ (def-package! nix-update :after nix-mode :commands (nix-update-fetch)) + +(def-package! nix-repl + :after nix-mode + :commands (nix-repl-show)) From 1dac12c9c0a79d300db950502c1b6fbf8eb1039d Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Mon, 16 Jul 2018 17:10:57 +0200 Subject: [PATCH 4/9] Add bindings for nix-mode --- modules/lang/nix/config.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/lang/nix/config.el b/modules/lang/nix/config.el index 3cb5d4078..4af40dc4c 100644 --- a/modules/lang/nix/config.el +++ b/modules/lang/nix/config.el @@ -13,3 +13,14 @@ (def-package! nix-repl :after nix-mode :commands (nix-repl-show)) + +(def-package! nix-mode + :config + (map! :map nix-mode-map + :localleader + :n "f" #'nix-update-fetch + :n "p" #'nix-format-buffer + :n "r" #'nix-repl-show + :n "s" #'nix-shell + :n "b" #'nix-build + :n "u" #'nix-unpack)) From 8ed5ea56d92db6b20e3b4918b1e29132921ef4f1 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Mon, 16 Jul 2018 17:13:53 +0200 Subject: [PATCH 5/9] Added doctor check for nixfmt --- modules/lang/nix/doctor.el | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 modules/lang/nix/doctor.el diff --git a/modules/lang/nix/doctor.el b/modules/lang/nix/doctor.el new file mode 100644 index 000000000..440ef31b0 --- /dev/null +++ b/modules/lang/nix/doctor.el @@ -0,0 +1,6 @@ +;; -*- lexical-binding: t; no-byte-compile: t; -*- +;;; lang/nix/doctor.el + +(unless (executable-find "nixfmt") + (warn! "Couldn't find nixfmt. nix-format-buffer won't work")) + From 6b236929857c7dd2c9536fb091b410963fd4c4a5 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Mon, 16 Jul 2018 17:15:05 +0200 Subject: [PATCH 6/9] Whoops! this is available on melpa after all --- modules/lang/nix/packages.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lang/nix/packages.el b/modules/lang/nix/packages.el index 6cd491c8b..2ffe1aab7 100644 --- a/modules/lang/nix/packages.el +++ b/modules/lang/nix/packages.el @@ -2,7 +2,7 @@ ;;; lang/nix/packages.el (package! nix-mode) -(package! nix-update :recipe (:fetcher github :repo "jwiegley/nix-update-el")) +(package! nix-update) (when (featurep! :completion company) (package! company-nixos-options)) From 0aa351842cd3498b8fcd8b1a7448932f8c825fc9 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Tue, 17 Jul 2018 09:56:52 +0200 Subject: [PATCH 7/9] clean-up + add helm-nixos-options --- modules/lang/nix/config.el | 25 ++++++++++++++----------- modules/lang/nix/packages.el | 4 ++++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/modules/lang/nix/config.el b/modules/lang/nix/config.el index 4af40dc4c..48c02ed82 100644 --- a/modules/lang/nix/config.el +++ b/modules/lang/nix/config.el @@ -1,21 +1,16 @@ ;;; config.el --- description -*- lexical-binding: t; -*- -(def-package! company-nixos-options - :when (featurep! :completion company) - :after nix-mode - :config - (set-company-backend! 'nix-mode 'company-nixos-options)) - (def-package! nix-update - :after nix-mode :commands (nix-update-fetch)) (def-package! nix-repl - :after nix-mode :commands (nix-repl-show)) -(def-package! nix-mode - :config +(def-package! helm-nixos-options + :when (featurep! :completion helm) + :commands (helm-nixos-options)) + +(after! nix-mode (map! :map nix-mode-map :localleader :n "f" #'nix-update-fetch @@ -23,4 +18,12 @@ :n "r" #'nix-repl-show :n "s" #'nix-shell :n "b" #'nix-build - :n "u" #'nix-unpack)) + :n "u" #'nix-unpack) + + (when (featurep! :completion helm) + (map! :map nix-mode-map + :localleader + :n "o" #'helm-nixos-options)) + + (when (featurep! :completion company) + (set-company-backend! 'nix-mode 'company-nixos-options))) diff --git a/modules/lang/nix/packages.el b/modules/lang/nix/packages.el index 2ffe1aab7..47ebff527 100644 --- a/modules/lang/nix/packages.el +++ b/modules/lang/nix/packages.el @@ -2,7 +2,11 @@ ;;; lang/nix/packages.el (package! nix-mode) + (package! nix-update) (when (featurep! :completion company) (package! company-nixos-options)) + +(when (featurep! :completion helm) + (package! helm-nixos-options)) From bd5d305e06408413b567171732d1f1d09b90a796 Mon Sep 17 00:00:00 2001 From: Patrick Elliott Date: Tue, 17 Jul 2018 10:03:17 +0200 Subject: [PATCH 8/9] Added doc check for nix package manager --- modules/lang/nix/doctor.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/lang/nix/doctor.el b/modules/lang/nix/doctor.el index 440ef31b0..93f4de0c3 100644 --- a/modules/lang/nix/doctor.el +++ b/modules/lang/nix/doctor.el @@ -1,6 +1,9 @@ ;; -*- lexical-binding: t; no-byte-compile: t; -*- ;;; lang/nix/doctor.el -(unless (executable-find "nixfmt") - (warn! "Couldn't find nixfmt. nix-format-buffer won't work")) +(unless (executable-find "nix") + (warn! "Couldn't find the nix package manager. nix-mode won't work.")) + +(unless (executable-find "nixfmt") + (warn! "Couldn't find nixfmt. nix-format-buffer won't work.")) From 7a81f46b39d02e412750ad8ef8d987f4ec4e00c5 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 17 Jul 2018 13:23:33 +0200 Subject: [PATCH 9/9] Refactor lang/nix + Move set-company-backend! out of conditional (it is an autodef, meaning it will simply no-op if the company module is disabled) + Removed helm-nixos-options config, because `helm-nixos-options` is already autoloaded by the package + Simplify map! usage + Move nix-mode to the top, as it is the focal package of this module --- modules/lang/nix/config.el | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/modules/lang/nix/config.el b/modules/lang/nix/config.el index 48c02ed82..b03095541 100644 --- a/modules/lang/nix/config.el +++ b/modules/lang/nix/config.el @@ -1,16 +1,8 @@ -;;; config.el --- description -*- lexical-binding: t; -*- - -(def-package! nix-update - :commands (nix-update-fetch)) - -(def-package! nix-repl - :commands (nix-repl-show)) - -(def-package! helm-nixos-options - :when (featurep! :completion helm) - :commands (helm-nixos-options)) +;;; lang/nix/config.el -*- lexical-binding: t; -*- (after! nix-mode + (set-company-backend! 'nix-mode 'company-nixos-options) + (map! :map nix-mode-map :localleader :n "f" #'nix-update-fetch @@ -18,12 +10,12 @@ :n "r" #'nix-repl-show :n "s" #'nix-shell :n "b" #'nix-build - :n "u" #'nix-unpack) + :n "u" #'nix-unpack + (:when (featurep! :completion helm) + :n "o" #'helm-nixos-options))) - (when (featurep! :completion helm) - (map! :map nix-mode-map - :localleader - :n "o" #'helm-nixos-options)) +(def-package! nix-update + :commands (nix-update-fetch)) - (when (featurep! :completion company) - (set-company-backend! 'nix-mode 'company-nixos-options))) +(def-package! nix-repl + :commands (nix-repl-show))