Function: nix-ts-mode
nix-ts-mode is an interactive and natively compiled function defined
in nix-ts-mode.el.
Signature
(nix-ts-mode)
Documentation
Major mode for editing Nix expressions, powered by treesitter.
In addition to any hooks its parent mode prog-mode might have run,
this mode runs the hook nix-ts-mode-hook, as the final or
penultimate step during initialization.
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/gfg1ybfpvhh7fr396dh1axr72lcm71n0-emacs-packages-deps/share/emacs/site-lisp/elpa/nix-ts-mode-20260705.1600/nix-ts-mode.el
;;;###autoload
(define-derived-mode nix-ts-mode prog-mode "Nix"
"Major mode for editing Nix expressions, powered by treesitter.
\\{nix-ts-mode-map}"
:syntax-table nix-ts-mode--syntax-table
(when (treesit-ready-p 'nix)
(treesit-parser-create 'nix)
;; Font locking
(setq-local treesit-font-lock-settings nix-ts-mode--font-lock-settings)
(setq-local treesit-font-lock-feature-list
'((comment builtin constant)
(string path uri)
(number operator definition function-call keyword)
(parameter property variable bracket delimiter ellipses punctuation paren-base parameter-atpattern error)))
;; Comments
(setq-local comment-start "# ")
(setq-local comment-start-skip "#+\\s-*")
;; Indentation
(setq-local treesit-simple-indent-rules nix-ts-mode-indent-rules)
;; Imenu.
(setq-local treesit-simple-imenu-settings
`((nil "\\`binding\\'" nil nil)))
;; Navigation.
(setq-local treesit-defun-type-regexp (rx (or "binding")))
(setq-local treesit-defun-name-function #'nix-ts-mode--defun-name)
(treesit-major-mode-setup))
(when (functionp 'derived-mode-add-parents)
(derived-mode-add-parents 'nix-ts-mode '(nix-mode))))