From fd06ba49bb7f7cac9e468e5838e5d0a729be2846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madeleine=20Sydney=20=C5=9Alaga?= Date: Sat, 20 Dec 2025 13:59:27 -0700 Subject: [PATCH] feat(emacs): nix-ts-mode --- modules/home/users/msyds/emacs/lisp/syd/nix.el | 8 +++++++- modules/home/users/msyds/emacs/lisp/syd/prelude.el | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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)