Subject: 30.0.92; tree-sitter elixir-ts-mode structural movement broken

From: Bart Otten <[email-masked]>
Date: Tue, 20 May 2025 00:10:54 +0200

Greetings and salutions,

Trying to use elixir treesit mode, it seems the navigation of defun and lists seems broken.

1.) `defmodule` is considered a function definition and so moving up from the first
actual function definition `def my_fun do` causes the point to jump to
'defmodule my_mod do'. Invoking `end-of-defun` jumps to the end of the defmodule block.
Effectively, you have been ejected from the module body.

;; current scoped workaround
;; does not jump up to defmodule when using `beginning-of-defun`
(defun elixir-ts--defun-p (node)
  "Return non-nil when NODE is a defun."
  (member (treesit-node-text
           (treesit-node-child-by-field-name node "target"))
          (append
           (remove "defmodule" elixir-ts--definition-keywords)
elixir-ts--test-definition-keywords)))

2.) When you use `down-list` while on a function definition line,
nothing happens. I tried to fix it, ony to find out that
`backward-up-list` will jump to `defmodule` when invoked while point is at a
function argument, instead of navigating out of the argument list only.  

Structural movement might need some extra love.

Cheers,
Bart

Major mode: Elixir

Minor modes in effect:
  electric-pair-mode: t
  eglot--managed-mode: t
  exunit-mode: t
  mix-minor-mode: t
  global-org-modern-mode: t
  display-line-numbers-mode: t
  global-treesit-auto-mode: t
  doom-modeline-mode: t
  which-key-mode: t
  org-super-agenda-mode: t
  undo-fu-session-global-mode: t
  undo-fu-session-mode: t
  apprentice-mode: t
  apprentice-hooks-mode: t
  flymake-mode: t
  yas-minor-mode: t
  treesit-inspect-mode: t
  global-visual-wrap-prefix-mode: t
  visual-wrap-prefix-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  prettify-symbols-mode: t