diff --git a/modules/home/users/msyds/emacs/lisp/syd/nix.el b/modules/home/users/msyds/emacs/lisp/syd/nix.el index ad23a5c..c6e8707 100644 --- a/modules/home/users/msyds/emacs/lisp/syd/nix.el +++ b/modules/home/users/msyds/emacs/lisp/syd/nix.el @@ -24,6 +24,12 @@ (push '(?Q . ("''" . "''")) evil-surround-pairs-alist))))) -(use-package nix-ts-mode) +(use-package nix-ts-mode + :config + ;; (add-to-list 'major-mode-remap-alist `(nix-mode . nix-ts-mode)) + (syd-remap-mode-to-ts 'nix-mode)) + +(with-eval-after-load 'project + (add-to-list 'project-vc-extra-root-markers "flake.nix")) (provide 'syd/nix) diff --git a/modules/home/users/msyds/emacs/lisp/syd/prelude.el b/modules/home/users/msyds/emacs/lisp/syd/prelude.el index 1fcc20c..a8451ed 100755 --- a/modules/home/users/msyds/emacs/lisp/syd/prelude.el +++ b/modules/home/users/msyds/emacs/lisp/syd/prelude.el @@ -182,4 +182,15 @@ form." ;; (user-error (concat "Ignoring a call to `lsp-install-server'" ;; " — tell the caller to use Nix!"))) +(defun syd-remap-mode-to-ts (mode) + "Given a symbol MODE of form *-mode, remap *-mode to *-ts-mode via +`major-mode-remap-alist'." + (let ((s (symbol-name mode))) + (if (string-match (rx bol (group (* any)) "-mode" eol) + s) + (add-to-list + 'major-mode-remap-alist + (cons mode (intern (concat (match-string 1 s) "-ts-mode")))) + (error "Symbol `%c' is not a mode." mode)))) + (provide 'syd/prelude)