branch: elpa/typst-ts-mode commit 379bcc0a8f94cbe5c57eb9da28e7cd6efa1a4aaa Author: Meow King <mr.meowk...@anche.no> Commit: Meow King <mr.meowk...@anche.no>
chore --- .env | 1 + justfile | 13 ++++++++++++- typst-ts-mode.el | 29 +++++++++++++++++++---------- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/.env b/.env new file mode 100644 index 0000000000..4cb6b3ed2d --- /dev/null +++ b/.env @@ -0,0 +1 @@ +TEST_FILE=/tmp/test.typ \ No newline at end of file diff --git a/justfile b/justfile index 57c3887583..9e04bc8b37 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,16 @@ +set dotenv-load + +emacs := env("EMACS", "emacs") +test-file := env("TEST_FILE", "./test/basic-syntax.typ") + +eval: + {{emacs}} -Q -L . --eval "(require 'typst-ts-mode)" {{test-file}} + +clean: + rm -f ./*.elc + els-settings-test: - emacs --batch -l ./typst-ts-utils.el \ + {{emacs}} --batch -l ./typst-ts-utils.el \ -l ./typst-ts-embedding-lang-settings.el \ -l ~/.config/emacs/.local/elpaca/repos/emacs-kotlin-ts-mode/kotlin-ts-mode.el \ -l ~/.config/emacs/.local/elpaca/repos/mermaid-ts-mode/mermaid-ts-mode.el \ diff --git a/typst-ts-mode.el b/typst-ts-mode.el index 4486d0e424..a7f88bc9b4 100644 --- a/typst-ts-mode.el +++ b/typst-ts-mode.el @@ -108,7 +108,7 @@ Like this: (setq typst-ts-mode-font-lock-rules (append (typst-ts-mode-font-lock-rules) - \='( + \='( :language typst :type custom ((el-psy-kongaroo) @el-psy-kongaroo)))) @@ -581,7 +581,7 @@ It should hold the originally value of `treesit-indent-function'.") (defun typst-ts-mode-indent (node parent bol) "Indent function for `treesit-indent-function'. This function basically call `typst-ts-mode-indent-function' (i.e. the original -`treesit-indent-function' to indent), and then it checks whether the current +`treesit-indent-function') to indent, and then it checks whether the current line has a local parser (i.e. raw block with highlight on). If it has, we add offset to the line to match the indentation of raw block label. NODE, PARENT and BOL see `treesit-indent-function'." @@ -752,6 +752,16 @@ typst tree sitter grammar (at least %s)!" (current-time-string min-time)) (add-hook 'post-self-insert-hook 'typst-ts-mode-electric-pair-open-newline-between-pairs-psif t)) + + ;; Set Compile Command + (ignore-errors + (unless compile-command + (setq-local + compile-command + (format "%s compile %s %s" + typst-ts-compile-executable-location + (file-name-nondirectory buffer-file-name) + typst-ts-compile-options)))) ;; it seems like the following code only works after-hook (when (and @@ -821,14 +831,13 @@ typst tree sitter grammar (at least %s)!" (current-time-string min-time)) typst-ts-mode--imenu-name-function) ("Headings" "^heading$" nil typst-ts-mode--imenu-name-function))) - ;; Compile Command - (ignore-errors - (setq-local - compile-command - (format "%s compile %s %s" - typst-ts-compile-executable-location - (file-name-nondirectory buffer-file-name) - typst-ts-compile-options))) + (setq-local treesit-defun-type-regexp + (regexp-opt '("let" "math"))) + + ;; treesit-defun-name-function + + ;; (setq-local treesit-thing-settings + ;; `((typst ()))) (when (>= emacs-major-version 30) (if (not typst-ts-mode-enable-raw-blocks-highlight)