Function: nix-ts-indent-multiline-string

nix-ts-indent-multiline-string is a natively compiled function defined in nix-ts-mode.el.

Signature

(nix-ts-indent-multiline-string N PARENT BOL &rest REST)

Documentation

Return the indent prefix for the current multi-line string line.

For the first line, this is the previous line offset+nix-indent-offset, and for subsequent lines it's the previous line's indentation.

Source Code

;; Defined in /nix/store/gfg1ybfpvhh7fr396dh1axr72lcm71n0-emacs-packages-deps/share/emacs/site-lisp/elpa/nix-ts-mode-20260705.1600/nix-ts-mode.el
;; Indentation
(defun nix-ts-indent-multiline-string (n parent bol &rest rest)
  "Return the indent prefix for the current multi-line string line.
For the first line, this is the previous line offset+nix-indent-offset,
and for subsequent lines it's the previous line's indentation."
  ;; If the current line is the first relevant one in the multiline
  ;; string, indent it to the default level (2 spaces past the
  ;; previous line's offset):
  (if (and (equal (treesit-node-child (treesit-node-parent parent) 1)
                  parent)
           (<= (count-lines (treesit-node-start parent) (point)) 1))
      (+ (apply (alist-get 'parent-bol treesit-simple-indent-presets)
                n parent bol rest)
         nix-ts-mode-indent-offset)
    ;; If the current line is already indented to some level, leave it alone:
    (if (/= bol
            (save-excursion
              (beginning-of-line)
              (point)))
        bol
      ;; otherwise, indent to the level of the previous line by default.
      (save-excursion
        (forward-line -1)
        (if (looking-at "\s+")
            (match-end 0)
          ;; in case neither line has discernable indentation, just
          ;; indent to bol
          bol)))))