doomemacs/modules/lang/nix/config.el
Henrik Lissner ad6a3d0f33
refactor: deprecate featurep! for modulep!
featurep! will be renamed modulep! in the future, so it's been
deprecated. They have identical interfaces, and can be replaced without
issue.

featurep! was never quite the right name for this macro. It implied that
it had some connection to featurep, which it doesn't (only that it was
similar in purpose; still, Doom modules are not features). To undo such
implications and be consistent with its namespace (and since we're
heading into a storm of breaking changes with the v3 release anyway),
now was the best opportunity to begin the transition.
2022-08-14 20:43:35 +02:00

57 lines
1.6 KiB
EmacsLisp

;;; lang/nix/config.el -*- lexical-binding: t; -*-
(after! tramp
(add-to-list 'tramp-remote-path "/run/current-system/sw/bin"))
;;
;;; Plugins
(use-package! nix-mode
:interpreter ("\\(?:cached-\\)?nix-shell" . +nix-shell-init-mode)
:mode "\\.nix\\'"
:init
;; Treat flake.lock files as json. Fall back to js-mode because it's faster
;; than js2-mode, and its extra features aren't needed there.
(add-to-list 'auto-mode-alist
(cons "/flake\\.lock\\'"
(if (modulep! :lang json)
'json-mode
'js-mode)))
:config
(set-repl-handler! 'nix-mode #'+nix/open-repl)
(set-company-backend! 'nix-mode 'company-nixos-options)
(set-lookup-handlers! 'nix-mode
:documentation '(+nix/lookup-option :async t))
(set-popup-rule! "^\\*nixos-options-doc\\*$" :ttl 0 :quit t)
;; Fix #3927: disable idle completion because `company-nixos-options' is
;; dreadfully slow. It can still be invoked manually..
(setq-hook! 'nix-mode-hook company-idle-delay nil)
(when (modulep! +lsp)
(add-hook 'nix-mode-local-vars-hook #'lsp! 'append))
(when (modulep! +tree-sitter)
(add-hook 'nix-mode-local-vars-hook #'tree-sitter! 'append))
(map! :localleader
:map nix-mode-map
"f" #'nix-update-fetch
"p" #'nix-format-buffer
"r" #'nix-repl-show
"s" #'nix-shell
"b" #'nix-build
"u" #'nix-unpack
"o" #'+nix/lookup-option))
(use-package! nix-drv-mode
:mode "\\.drv\\'")
(use-package! nix-update
:commands nix-update-fetch)
(use-package! nix-repl
:commands nix-repl-show)