mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-23 19:40:24 +10:00
Moving to Doom Emacs!
This commit is contained in:
41
.emacs.d/modules/lang/nix/autoload.el
Normal file
41
.emacs.d/modules/lang/nix/autoload.el
Normal file
@@ -0,0 +1,41 @@
|
||||
;;; lang/nix/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defun +nix--options-action (candidate)
|
||||
(switch-to-buffer-other-window
|
||||
(nixos-options-doc-buffer
|
||||
(nixos-options-get-documentation-for-option candidate))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +nix/lookup-option (&optional initial-input)
|
||||
"Look up documentation on a nix option."
|
||||
(interactive
|
||||
(list
|
||||
;; REVIEW Must be a better way to do this
|
||||
(when (and (looking-at-p "[a-zA-Z0-9-_\\.]")
|
||||
(not (doom-point-in-string-or-comment-p)))
|
||||
(buffer-substring-no-properties
|
||||
(save-excursion
|
||||
(skip-chars-backward "^ ")
|
||||
(point))
|
||||
(save-excursion
|
||||
(skip-chars-forward "^ ")
|
||||
(point))))))
|
||||
(cond ((featurep! :completion helm)
|
||||
(require 'helm-nixos-options)
|
||||
;; REVIEW We reimplment `helm-nixos-options' so we can supply
|
||||
;; `initial-input'. Maybe use `helm-attrset' instead?
|
||||
(helm :sources `(,(helm-source-nixos-options-search))
|
||||
:buffer "*helm-nixos-options*"
|
||||
:input initial-input))
|
||||
((featurep! :completion ivy)
|
||||
(require 'nixos-options)
|
||||
(ivy-read "NixOS options: "
|
||||
nixos-options
|
||||
:require-match t
|
||||
:initial-input initial-input
|
||||
:action #'+nix--options-action
|
||||
:caller '+nix/options))
|
||||
;; TODO Add general `completing-read' support
|
||||
((user-error "No search engine is enabled. Enable helm or ivy!")))
|
||||
;; Tell lookup module to let us handle things from here
|
||||
'deferred)
|
||||
27
.emacs.d/modules/lang/nix/config.el
Normal file
27
.emacs.d/modules/lang/nix/config.el
Normal file
@@ -0,0 +1,27 @@
|
||||
;;; lang/nix/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(use-package! nix-mode
|
||||
:mode "\\.nix\\'"
|
||||
:config
|
||||
(set-company-backend! 'nix-mode 'company-nixos-options)
|
||||
(set-lookup-handlers! 'nix-mode
|
||||
:documentation '(+nix/lookup-option :async t))
|
||||
|
||||
(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)
|
||||
9
.emacs.d/modules/lang/nix/doctor.el
Normal file
9
.emacs.d/modules/lang/nix/doctor.el
Normal file
@@ -0,0 +1,9 @@
|
||||
;; -*- lexical-binding: t; no-byte-compile: t; -*-
|
||||
;;; lang/nix/doctor.el
|
||||
|
||||
(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."))
|
||||
|
||||
11
.emacs.d/modules/lang/nix/packages.el
Normal file
11
.emacs.d/modules/lang/nix/packages.el
Normal file
@@ -0,0 +1,11 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; 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))
|
||||
Reference in New Issue
Block a user