diff --git a/CHANGELOG.md b/CHANGELOG.md index 238bb73..7e654cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## main (unreleased) - Add custom option `clojure-ts-toplevel-inside-comment-form` as an equivalent to `clojure-toplevel-inside-comment-form` in clojure-mode (#30) +- Change behavior of `beginning-of-defun` and `end-of-defun` to consider all Clojure sexps as defuns (#32) ## 0.2.0 diff --git a/clojure-ts-mode.el b/clojure-ts-mode.el index 5e50ffa..f740dda 100644 --- a/clojure-ts-mode.el +++ b/clojure-ts-mode.el @@ -917,10 +917,13 @@ See `clojure-ts--font-lock-settings' for usage of MARKDOWN-AVAILABLE." (setq-local treesit-defun-prefer-top-level t) (setq-local treesit-defun-tactic 'top-level) (setq-local treesit-defun-type-regexp - (cons (rx (or "list_lit" "vec_lit" "map_lit")) - (lambda (node) - (or (not clojure-ts-toplevel-inside-comment-form) - (not (clojure-ts--definition-node-p "comment" node)))))) + (cons + ;; consider all clojure sexps as valid top level forms... + (regexp-opt clojure-ts--sexp-nodes) + ;; ...except `comment' forms if `clojure-ts-toplevel-inside-comment-form' is set + (lambda (node) + (or (not clojure-ts-toplevel-inside-comment-form) + (not (clojure-ts--definition-node-p "comment" node)))))) (setq-local treesit-simple-indent-rules (clojure-ts--configured-indent-rules)) (setq-local treesit-defun-name-function