diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el index 7edf42c2489..b98a1fb96e8 100644 --- a/lisp/progmodes/elixir-ts-mode.el +++ b/lisp/progmodes/elixir-ts-mode.el @@ -792,9 +792,15 @@ Return nil if NODE is not a defun node or doesn't have a name." heex-ts--font-lock-feature-list))) (treesit-major-mode-setup) + (setq-local syntax-propertize-function #'elixir-ts--syntax-propertize) + ;; Enable the 'sexp' navigation by default - (treesit-cycle-sexp-type))) + (setq-local forward-sexp-function #'treesit-forward-sexp + treesit-sexp-type-regexp 'sexp + ;; But still use 'list' for `down-list' and `up-list' + treesit-sexp-type-down-list 'list + treesit-sexp-type-up-list 'list))) (derived-mode-add-parents 'elixir-ts-mode '(elixir-mode)) diff --git a/lisp/treesit.el b/lisp/treesit.el index 68de843ce4d..5df8eb70cbf 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2981,6 +2981,14 @@ delimits medium sized statements in the source code. It is, however, smaller in scope than sentences. This is used by `treesit-forward-sexp' and friends.") +(defvar-local treesit-sexp-type-down-list nil + "A regexp that matches the sexp nodes for `down-list'. +This is used by `treesit-down-list'.") + +(defvar-local treesit-sexp-type-up-list nil + "A regexp that matches the sexp nodes for `up-list'. +This is used by `treesit-up-list'.") + ;; Avoid interpreting the symbol `list' as a function. (put 'list 'treesit-thing-symbol t) @@ -3126,7 +3134,9 @@ redefined by the variable `down-list-function'. ARG is described in the docstring of `down-list'." (interactive "^p") - (let* ((pred (or treesit-sexp-type-regexp 'list)) + (let* ((pred (or treesit-sexp-type-down-list + treesit-sexp-type-regexp + 'list)) (arg (or arg 1)) (cnt arg) (inc (if (> arg 0) 1 -1))) @@ -3142,7 +3152,8 @@ ARG is described in the docstring of `down-list'." (treesit-thing-prev (point) pred))) (child (when sibling (treesit-node-child sibling (if (> arg 0) 0 -1))))) - (or (when (and (null treesit-sexp-type-regexp) + (or (when (and (null (or treesit-sexp-type-down-list + treesit-sexp-type-regexp)) default-pos (or (null child) (if (> arg 0) @@ -3167,7 +3178,9 @@ redefined by the variable `up-list-function'. ARG is described in the docstring of `up-list'." (interactive "^p") - (let* ((pred (or treesit-sexp-type-regexp 'list)) + (let* ((pred (or treesit-sexp-type-up-list + treesit-sexp-type-regexp + 'list)) (arg (or arg 1)) (treesit--parser-overlay-offset -1) (cnt arg) @@ -3195,7 +3208,8 @@ ARG is described in the docstring of `up-list'." (treesit-node-at (point) (car parsers)) pred) parsers (cdr parsers))))) - (or (when (and (null treesit-sexp-type-regexp) + (or (when (and (null (or treesit-sexp-type-up-list + treesit-sexp-type-regexp)) default-pos (or (null parent) (if (> arg 0)