-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path+nix.el
More file actions
61 lines (52 loc) · 2.26 KB
/
+nix.el
File metadata and controls
61 lines (52 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
;;; +nix.el -*- lexical-binding: t; -*-
(map! :after nix-mode
:map nix-mode-map
:localleader
"p" #'+format/region-or-buffer ;; replace nix-mode's format binding with that from doom-code-map (SPC c), i.e. format-all module
"f" #'nix-flake)
(map! :after nix-repl
:map nix-mode-map
:ni "C-c C-z" #'+nix/switch-to-repl-buffer
:localleader
"r" #'+nix/switch-to-repl-buffer)
(map! :after nix-repl
:map nix-repl-mode-map
:ni "C-c C-z" #'+nix/switch-to-last-nix-buffer
:ni "C-p" #'comint-previous-input
:ni "C-n" #'comint-next-input
:ni "C-r" #'comint-history-isearch-backward-regexp
:ni "C-l" #'comint-clear-buffer
:ni "C-u" #'comint-kill-input
:i "C-d" #'delete-forward-char
:n "RET" #'comint-send-input)
(after! nix-mode
(add-hook! 'nix-mode-hook (nix-prettify-mode t))
(set-repl-handler! 'nix-mode #'+nix/switch-to-repl-buffer)
(set-formatter! 'alejandra '("alejandra" "-") :modes '(nix-mode))
(set-formatter! 'nixpkgs-fmt '("nixpkgs-fmt") :modes '(nix-mode)))
(after! nix-repl
(set-popup-rule! "^\\*Nix-REPL" :size 0.3 :quit nil :select t)
(add-hook! 'nix-repl-mode-hook (nix-prettify-mode t))
(add-hook! 'nix-repl-mode-hook
(let ((repl-file (doom-project-expand "repl.nix")))
(when (file-exists-p repl-file)
(setq-local nix-repl-executable-args (list "repl" "--file" repl-file))
(print! "Configured nix-repl file: %s" repl-file)))))
(after! lsp-nix
(setq lsp-nix-nil-formatter ["alejandra"]
lsp-nix-nixd-nixpkgs-expr
"import <nixpkgs> {}"
;; (format "import (builtins.getFlake\"%s\").inputs.nixpkgs {}"
;; (or (getenv "FLAKE_ROOT")
;; (getenv "DOTFILES_DIR")
;; (expand-file-name "~/.dotfiles")))
)
;; TODO lsp-nix-nixd-nixos-options-expr
;; (when (string-prefix-p "Logan-Gamma" (system-name))
;; (setq lsp-nix-nixd-home-manager-options-expr
;; (format "(builtins.getFlake \"%s\").darwinConfigurations.logamma.options.home-manager"
;; (or (getenv "DOTFILES_DIR")
;; (expand-file-name "~/.dotfiles")))))
)
(after! (:and evil nix-repl)
(set-evil-initial-state! 'nix-repl-mode 'insert))