Skip to content

Instantly share code, notes, and snippets.

@lispandfound
Last active July 7, 2024 23:56
Show Gist options
  • Save lispandfound/a72f2dda6b8c1292860f274ffba6f595 to your computer and use it in GitHub Desktop.
Save lispandfound/a72f2dda6b8c1292860f274ffba6f595 to your computer and use it in GitHub Desktop.
Expand region treesitter integration
(defun treesit-mark-bigger-node ()
(interactive)
(let* ((node (treesit-node-on (region-beginning) (region-end))))
(let ((next-node (treesit-parent-until node (lambda (n)
(not (and
(= (region-beginning) (treesit-node-start n))
(= (region-end) (treesit-node-end n))))))))
(set-mark (treesit-node-end next-node))
(goto-char (treesit-node-start next-node)))))
(defun er-use-treesit-expansions ()
(setq-local er/try-expand-list '(er/mark-word treesit-mark-bigger-node)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment