feat(emacs): nix-ts-mode

This commit is contained in:
2025-12-20 13:59:27 -07:00
parent 1b327727e9
commit fd06ba49bb
2 changed files with 18 additions and 1 deletions

View File

@@ -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)

View File

@@ -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)