30 lines
861 B
EmacsLisp
30 lines
861 B
EmacsLisp
;;; syd-lang-nix.el -*- lexical-binding: t; -*-
|
|
|
|
(require 'syd-handle-repl)
|
|
(require 'syd-handle-lookup)
|
|
|
|
(defun syd-nix-open-nix-repl ()
|
|
(interactive)
|
|
;; If possible, cd to the project root. Flakes force you to use relative
|
|
;; paths, which can be annoying in combination with
|
|
;;
|
|
;; REVIEW: Should this be something handled by `syd--call-repl-handler'?
|
|
(-some-> (syd-project-root) cd)
|
|
(nix-repl)
|
|
(current-buffer))
|
|
|
|
(use-package nix-mode
|
|
:mode "\\.nix\\'"
|
|
:init
|
|
(add-to-list 'auto-mode-alist
|
|
(cons (rx "/flake.lock'")
|
|
(if (fboundp 'json-mode)
|
|
'json-mode
|
|
'js-mode)))
|
|
:config
|
|
(add-hook 'nix-mode-hook #'lsp)
|
|
(set-popup-rule! "^\\*nixos-options-doc\\*$" :ttl 0 :quit t)
|
|
(set-repl-handler! 'nix-mode #'syd-nix-open-nix-repl))
|
|
|
|
(provide 'syd-lang-nix)
|