branch: elpa/typst-ts-mode
commit d6cd6d728342c60bf837ceee43d42093bf6f52c9
Author: Huan Nguyen <nguyenthieuh...@gmail.com>
Commit: Huan Nguyen <nguyenthieuh...@gmail.com>

    feat: Also auto insert numbered list.
---
 typst-ts-mode.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/typst-ts-mode.el b/typst-ts-mode.el
index 090e317ef4..0612fc5af9 100644
--- a/typst-ts-mode.el
+++ b/typst-ts-mode.el
@@ -1002,13 +1002,17 @@ This only works for syntax on 
https://typst.app/docs/reference/syntax/.";
   "Insert an item after NODE.
 NODE must be an item node!
 This function respects indentation."
-  (let (;; + or -
-       (item-type (treesit-node-text
-                   (treesit-node-child node 0)))
-       (item-end (treesit-node-end node)))
+  (let* (;; +, -, or <num>.
+        (item-type (treesit-node-text
+                    (treesit-node-child node 0)))
+         (item-number (string-to-number item-type))
+         (item-end (treesit-node-end node)))
     (goto-char item-end)
     (newline-and-indent)
-    (insert item-type " ")))
+    (insert (if (= item-number 0)
+                item-type
+              (concat (number-to-string (1+ item-number)) "."))
+            " ")))
 
 (defun typst-ts-mode-insert--heading (node)
   "Insert a heading after the section that NODE is part of."

Reply via email to