branch: elpa/typst-ts-mode
commit 71e180e4a0c83345b7a836de861ce395a2256bad
Author: Huan Nguyen <[email protected]>
Commit: Huan Nguyen <[email protected]>
reformat: whitespace cleanup and indenting
---
typst-ts-edit-indirect.el | 1 -
typst-ts-editing.el | 58 +++++++++++++++++++++++------------------------
typst-ts-misc-commands.el | 2 +-
typst-ts-mode.el | 34 +++++++++++++--------------
typst-ts-transient.el | 4 ++--
5 files changed, 49 insertions(+), 50 deletions(-)
diff --git a/typst-ts-edit-indirect.el b/typst-ts-edit-indirect.el
index b8a4f5ff5e..cb282dfd26 100644
--- a/typst-ts-edit-indirect.el
+++ b/typst-ts-edit-indirect.el
@@ -123,4 +123,3 @@ If there is no fitting mode or no lang it will be
`normal-mode'."
(provide 'typst-ts-edit-indirect)
;;; typst-ts-edit-indirect.el ends here
-
diff --git a/typst-ts-editing.el b/typst-ts-editing.el
index 2626d7f3e0..bd251e25c9 100644
--- a/typst-ts-editing.el
+++ b/typst-ts-editing.el
@@ -53,7 +53,7 @@
"Whether the current line is a heading.
Return the heading node when yes otherwise nil."
(let ((node (treesit-node-parent
- (treesit-node-at
+ (treesit-node-at
(save-excursion
(beginning-of-line-text)
(point))))))
@@ -70,24 +70,24 @@ Return the heading node when yes otherwise nil."
When there is no relevant action to do it will execute the relevant function in
the `GLOBAL-MAP' (example: `right-word')."
(let ((heading (typst-ts-mode-heading--at-point-p))
- ;; car function, cdr string of function for
`substitute-command-keys'
- (call-me/string
- (pcase direction
- ('left
- (cons #'outline-promote
- "\\[typst-ts-mode-heading-decrease]"))
- ('right
- (cons #'outline-demote
- "\\[typst-ts-mode-heading-decrease]"))
- ('up
- (cons #'outline-move-subtree-up
- "\\[typst-ts-mode-heading-up]"))
- ('down
- (cons #'outline-move-subtree-down
- "\\[typst-ts-mode-heading-down]"))
- (_ (error "%s is not one of: `right' `left'" direction)))))
+ ;; car function, cdr string of function for `substitute-command-keys'
+ (call-me/string
+ (pcase direction
+ ('left
+ (cons #'outline-promote
+ "\\[typst-ts-mode-heading-decrease]"))
+ ('right
+ (cons #'outline-demote
+ "\\[typst-ts-mode-heading-decrease]"))
+ ('up
+ (cons #'outline-move-subtree-up
+ "\\[typst-ts-mode-heading-up]"))
+ ('down
+ (cons #'outline-move-subtree-down
+ "\\[typst-ts-mode-heading-down]"))
+ (_ (error "%s is not one of: `right' `left'" direction)))))
(if heading
- (call-interactively (car call-me/string))
+ (call-interactively (car call-me/string))
(call-interactively
(keymap-lookup global-map (substitute-command-keys (cdr
call-me/string)))))))
@@ -153,8 +153,8 @@ When prefix ARG is non-nil, call global return function."
NODE must be an item node!
This function respects indentation."
(let* (;; +, -, or <num>.
- (item-type (treesit-node-text
- (treesit-node-child node 0)))
+ (item-type (treesit-node-text
+ (treesit-node-child node 0)))
(item-number (string-to-number item-type))
(item-end (treesit-node-end node))
(node-bol-column (typst-ts-core-column-at-pos
@@ -171,14 +171,14 @@ This function respects indentation."
"Insert a heading after the section that NODE is part of.
When there is no section it will insert a heading below point."
(let* ((section
- (treesit-parent-until
- node
- (lambda (node)
- (string= (treesit-node-type node) "section"))
- t))
- ;; first child is heading
- (heading (treesit-node-child section 0))
- (heading-level (treesit-node-type (treesit-node-child heading
0))))
+ (treesit-parent-until
+ node
+ (lambda (node)
+ (string= (treesit-node-type node) "section"))
+ t))
+ ;; first child is heading
+ (heading (treesit-node-child section 0))
+ (heading-level (treesit-node-type (treesit-node-child heading 0))))
(if section
(goto-char (treesit-node-end section))
;; no headings so far
@@ -211,7 +211,7 @@ When there is no section it will insert a heading below
point."
((equal parent-node-type "raw_blck")
(insert-tab)
(throw 'execute-result 'success))
-
+
((or (equal cur-node-type "parbreak")
(equal parent-node-type "item")
;; please turn on whitespace-mode to test the following
conditions
diff --git a/typst-ts-misc-commands.el b/typst-ts-misc-commands.el
index 1031675999..62ebd81c1c 100644
--- a/typst-ts-misc-commands.el
+++ b/typst-ts-misc-commands.el
@@ -38,7 +38,7 @@
(defun typst-ts-mc-export-to-markdown ()
(interactive)
-
+
;; for simplicity
(unless buffer-file-name
(user-error "You should save the file first!"))
diff --git a/typst-ts-mode.el b/typst-ts-mode.el
index e12f65b8e8..0b1a891772 100644
--- a/typst-ts-mode.el
+++ b/typst-ts-mode.el
@@ -154,17 +154,17 @@ BLOB-NODE."
(bne (treesit-node-end blob-node))
(lang-node? (treesit-node-prev-sibling blob-node))
lang-node lang lang-mode)
-
+
(when (equal (treesit-node-type lang-node?) "ident")
(setq lang-node lang-node?))
-
+
(when lang-node
(setq lang (gethash
(downcase (treesit-node-text lang-node))
typst-ts-els-tag-lang-map))
(when lang
(setq lang-mode (typst-ts-els-get-lang-mode (symbol-name lang)))))
-
+
(if lang-mode
(typst-ts-els-fontify-raw-block lang-mode bns bne)
(put-text-property bns bne 'face 'typst-ts-markup-rawblock-blob-face))))
@@ -194,7 +194,7 @@ If you want to customize the rules, please customize the
same name variable
(label) @typst-ts-markup-label-face
(ref) @typst-ts-markup-reference-face))
('middle
- `((heading _ @typst-ts-markup-header-indicator-face (text)
@typst-ts-markup-header-face)
+ `((heading _ @typst-ts-markup-header-indicator-face (text)
@typst-ts-markup-header-face)
(emph) @typst-ts-markup-emphasis-face
(strong) @typst-ts-markup-strong-face
(item
@@ -233,7 +233,7 @@ If you want to customize the rules, please customize the
same name variable
(text) @typst-ts-markup-header-face-5)
(heading "======" @typst-ts-markup-header-indicator-face-6
(text) @typst-ts-markup-header-face-6)))
- ;; TODO performance enhancement
+ ;; TODO performance enhancement
(emph
"_" @typst-ts-markup-emphasis-indicator-face
(text) @typst-ts-markup-emphasis-face
@@ -413,14 +413,14 @@ See `treesit-simple-indent-rules'."
(prev-nonwhite-line-node
(treesit-node-at prev-nonwhite-pos))
((equal (treesit-node-type prev-nonwhite-line-node) "linebreak"))
-
+
(prev-nonwhite-line-heading-node
(save-excursion
(goto-char prev-nonwhite-pos)
(back-to-indentation)
(treesit-node-at (point))))
((equal (treesit-node-type prev-nonwhite-line-heading-node) "-"))
-
+
(prev-nonwhite-line-top-node (treesit-node-parent
prev-nonwhite-line-heading-node)))
(equal (treesit-node-type prev-nonwhite-line-top-node) "item")))
@@ -469,13 +469,13 @@ NODE, PARENT and BOL see `treesit-simple-indent-rules'."
;; 1. `toggle-debug-on-error' to make sure you indentation code error report
;; 2. enable `treesit--indent-verbose' to see what indentation rule matches
;; 3. `treesit-inspect-mode' or `treesit-inspect-node-at-point'
-
+
;; `indentation-test.typ' file is used for testing indentation.
;; no-node situation: often in insert mode > hit return at the line ending
;; `typst-ts-mode-indent-line-function' is created for handling end of buffer
;; edge cases
-
+
;; Note electric-pair-mode will auto insert newline character when condition
meets
;; see `typst-ts-mode-electric-pair-open-newline-between-pairs-psif'
;; It may be better to turn off `electric-pair-open-newline-between-pairs'
@@ -486,7 +486,7 @@ NODE, PARENT and BOL see `treesit-simple-indent-rules'."
;; (treesit-node-parent (treesit-node-parent parent)) bol)
;; nil)
;; parent-bol 0)
-
+
((and no-node (parent-is "source_file")) prev-line 0)
((parent-is "source_file") column-0 0)
@@ -494,7 +494,7 @@ NODE, PARENT and BOL see `treesit-simple-indent-rules'."
,typst-ts-mode--container-node-types-regexp
nil)
parent-bol 0)
-
+
;; math
;; math align, example:
;; sum_(k=0)^n k
@@ -539,7 +539,7 @@ NODE, PARENT and BOL see `treesit-simple-indent-rules'."
;; whether normally or in insertion, the current node is always nil...
((n-p-gp nil "blob" "raw_blck")
no-indent 0)
-
+
((match "```" "raw_blck" nil 2 3 )
parent-bol 0)
@@ -598,7 +598,7 @@ NODE, PARENT and BOL see `treesit-simple-indent-rules'."
(save-excursion
(end-of-line)
(if (re-search-backward typst-ts-mode-outline-regexp nil t)
- (- (match-end 1) (match-beginning 1))
+ (- (match-end 1) (match-beginning 1))
0)))
@@ -616,13 +616,13 @@ FILE: file path for the result compile file."
"C-c C-c C" #'typst-ts-compile
"C-c C-c w" #'typst-ts-watch-mode
"C-c C-c p" #'typst-ts-mode-preview
-
+
"M-<left>" #'typst-ts-mode-heading-decrease
"M-<right>" #'typst-ts-mode-heading-increase
"M-<down>" #'typst-ts-mode-heading-down
"M-<up>" #'typst-ts-mode-heading-up
"M-<return>" #'typst-ts-mode-meta-return
-
+
;; don't bind <return>
;; Binding a command to "<return>" is generally a bug.
;; Emacs will first look for a binding for `return` and if it finds one
@@ -707,7 +707,7 @@ typst tree sitter grammar (at least %s)!"
(current-time-string min-time))
:syntax-table typst-ts-mode-syntax-table
:after-hook
(typst-ts-mode-after-hook-function)
-
+
(unless (treesit-ready-p 'typst)
(user-error "Tree-sitter for Typst isn't available"))
@@ -745,7 +745,7 @@ typst tree sitter grammar (at least %s)!"
(current-time-string min-time))
(setq-local treesit-defun-type-regexp
(regexp-opt '("let" "math")))
-
+
;; treesit-defun-name-function
;; (setq-local treesit-thing-settings
diff --git a/typst-ts-transient.el b/typst-ts-transient.el
index 1db16983c9..fbf21287fb 100644
--- a/typst-ts-transient.el
+++ b/typst-ts-transient.el
@@ -32,10 +32,10 @@
("C" "compile" typst-ts-compile)
("w" "watch" typst-ts-watch-mode)
("p" "preview" typst-ts-mode-preview)]
-
+
["Export"
("em" "markdown" typst-ts-mc-export-to-markdown)]
-
+
["Search"
("ss" "symbol" typst-ts-mc-search-typst-symbol)
("sr" "recognize symbol" typst-ts-mc-recognize-typst-symbol)