Function: go-mod-ts-mode--in-directive-p

go-mod-ts-mode--in-directive-p is a byte-compiled function defined in go-ts-mode.el.gz.

Signature

(go-mod-ts-mode--in-directive-p)

Documentation

Return non-nil if point is inside a directive.

When entering an empty directive or adding a new entry to one, no node will be present meaning none of the indentation rules will match, because there is no parent to match against. This function determines what the parent of the node would be if it were a node.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/go-ts-mode.el.gz
(defun go-mod-ts-mode--in-directive-p ()
  "Return non-nil if point is inside a directive.
When entering an empty directive or adding a new entry to one, no node
will be present meaning none of the indentation rules will match,
because there is no parent to match against.  This function determines
what the parent of the node would be if it were a node."
  (lambda (node _ _ &rest _)
    (unless (treesit-node-type node)
      (save-excursion
        (backward-up-list)
        (back-to-indentation)
        (pcase (treesit-node-type (treesit-node-at (point)))
          ("exclude" t)
          ("module" t)
          ("replace" t)
          ("require" t)
          ("retract" t))))))