diff options
| author | Juri Linkov | 2025-04-20 20:39:41 +0300 |
|---|---|---|
| committer | Juri Linkov | 2025-04-20 20:39:41 +0300 |
| commit | 25854625332b0f751e0cea3e4d598023cbfc2781 (patch) | |
| tree | 9eb64cb07e0c45f3c22dc29335f19ded6309cfb2 | |
| parent | 8c04396b198e81c1467314e44b720e3322ca8643 (diff) | |
| download | emacs-25854625332b0f751e0cea3e4d598023cbfc2781.tar.gz emacs-25854625332b0f751e0cea3e4d598023cbfc2781.zip | |
Fix indentation test failure for elixir-ts--indent-rules
* lisp/progmodes/elixir-ts-mode.el (elixir-ts--indent-rules):
Add query for Elixir embedded in Heex (bug#76788).
* lisp/progmodes/heex-ts-mode.el (heex-ts-mode): Append
treesit-simple-indent-rules to elixir-ts--indent-rules.
| -rw-r--r-- | lisp/progmodes/elixir-ts-mode.el | 16 | ||||
| -rw-r--r-- | lisp/progmodes/heex-ts-mode.el | 5 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lisp/progmodes/elixir-ts-mode.el b/lisp/progmodes/elixir-ts-mode.el index 3a136894454..f7d6932c7c2 100644 --- a/lisp/progmodes/elixir-ts-mode.el +++ b/lisp/progmodes/elixir-ts-mode.el | |||
| @@ -244,7 +244,21 @@ | |||
| 244 | (defvar elixir-ts--indent-rules | 244 | (defvar elixir-ts--indent-rules |
| 245 | (let ((offset elixir-ts-indent-offset)) | 245 | (let ((offset elixir-ts-indent-offset)) |
| 246 | `((elixir | 246 | `((elixir |
| 247 | ((parent-is "^source$") column-0 0) | 247 | ((parent-is "^source$") |
| 248 | ,(lambda (_node _parent bol &rest _) | ||
| 249 | ;; If Elixir is embedded indent to parent | ||
| 250 | ;; otherwise indent to the bol. | ||
| 251 | (if (treesit-local-parsers-at (point)) | ||
| 252 | (save-excursion | ||
| 253 | (goto-char (treesit-node-start | ||
| 254 | (treesit-node-at bol 'heex))) | ||
| 255 | (back-to-indentation) | ||
| 256 | (point)) | ||
| 257 | (pos-bol))) | ||
| 258 | ,(lambda (_node _parent _bol &rest _) | ||
| 259 | (if (treesit-local-parsers-at (point)) | ||
| 260 | elixir-ts-indent-offset | ||
| 261 | 0))) | ||
| 248 | ((parent-is "^string$") parent-bol 0) | 262 | ((parent-is "^string$") parent-bol 0) |
| 249 | ((parent-is "^quoted_content$") | 263 | ((parent-is "^quoted_content$") |
| 250 | (lambda (_n parent bol &rest _) | 264 | (lambda (_n parent bol &rest _) |
diff --git a/lisp/progmodes/heex-ts-mode.el b/lisp/progmodes/heex-ts-mode.el index a5fc6e2e232..2d6dce784bc 100644 --- a/lisp/progmodes/heex-ts-mode.el +++ b/lisp/progmodes/heex-ts-mode.el | |||
| @@ -188,6 +188,7 @@ Return nil if NODE is not a defun node or doesn't have a name." | |||
| 188 | 188 | ||
| 189 | (defvar elixir-ts--font-lock-settings) | 189 | (defvar elixir-ts--font-lock-settings) |
| 190 | (defvar elixir-ts--font-lock-feature-list) | 190 | (defvar elixir-ts--font-lock-feature-list) |
| 191 | (defvar elixir-ts--indent-rules) | ||
| 191 | (defvar elixir-ts--thing-settings) | 192 | (defvar elixir-ts--thing-settings) |
| 192 | 193 | ||
| 193 | ;;;###autoload | 194 | ;;;###autoload |
| @@ -244,6 +245,10 @@ Return nil if NODE is not a defun node or doesn't have a name." | |||
| 244 | treesit-font-lock-feature-list | 245 | treesit-font-lock-feature-list |
| 245 | elixir-ts--font-lock-feature-list)) | 246 | elixir-ts--font-lock-feature-list)) |
| 246 | 247 | ||
| 248 | (setq-local treesit-simple-indent-rules | ||
| 249 | (append treesit-simple-indent-rules | ||
| 250 | elixir-ts--indent-rules)) | ||
| 251 | |||
| 247 | (setq-local treesit-thing-settings | 252 | (setq-local treesit-thing-settings |
| 248 | (append treesit-thing-settings | 253 | (append treesit-thing-settings |
| 249 | `((elixir ,@elixir-ts--thing-settings))))) | 254 | `((elixir ,@elixir-ts--thing-settings))))) |