branch: elpa/typst-ts-mode
commit 380a0e566b22fdc9c4e67706dcc91926f2356076
Author: meowking <[email protected]>
Commit: meowking <[email protected]>
fix: issues found by melpazoid #42
---
typst-ts-editing.el | 17 +++++++++--------
typst-ts-faces.el | 6 +++---
typst-ts-misc-commands.el | 6 ++++++
typst-ts-mode.el | 6 +++++-
typst-ts-variables.el | 4 ++--
5 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/typst-ts-editing.el b/typst-ts-editing.el
index f69d968cff..a734dd1a4e 100644
--- a/typst-ts-editing.el
+++ b/typst-ts-editing.el
@@ -512,6 +512,7 @@ When there is no section it will insert a heading below
point."
(indent-according-to-mode)))
(defun typst-ts-editing--indent-item-node-lines (node offset)
+ "Indent lines covered by NODE by OFFSET."
(let ((item-node-min-column
(typst-ts-core-column-at-pos
(typst-ts-core-line-bol-nonwhite-pos
@@ -578,13 +579,13 @@ When there is no section it will insert a heading below
point."
(offset
(- cur-item-node-start-column
prev-item-node-start-column)))
- (if (>= offset typst-ts-editing-indent-offset)
+ (if (>= offset typst-ts-indent-offset)
(typst-ts-editing--indent-item-node-lines
cur-item-node
- (- (+ offset typst-ts-editing-indent-offset)))
+ (- (+ offset typst-ts-indent-offset)))
(typst-ts-editing--indent-item-node-lines
cur-item-node
- (- typst-ts-editing-indent-offset (abs offset)))))
+ (- typst-ts-indent-offset (abs offset)))))
'success)))))
;; execute default action if not successful
@@ -614,14 +615,14 @@ When there is no section it will insert a heading below
point."
(when fill-prefix (do-auto-fill)))))
(defun typst-ts-editing-symbol-picker ()
- "Insert elements from `typst-ts-editing-symbol-alist'
`typst-ts-editing-emoji-alist'.
-
+ "Insert typst symbols.
+Symbols are from `typst-ts-symbol-alist' `typst-ts-emoji-alist'.
In markup mode, it will prefix the selection with \"#\"
and its corresponding module (\"sym.\", \"emoji.\").
In math mode, symbols do not need a \"#\" prefix and \"sym.\" prefix.
In code mode, the selection needs to be prefixed with the module."
(interactive)
- (let* ((all-symbols (append typst-ts-editing-symbol-alist
typst-ts-editing-emoji-alist))
+ (let* ((all-symbols (append typst-ts-symbol-alist typst-ts-emoji-alist))
(completion-extra-properties
'(:annotation-function
(lambda (key)
@@ -641,8 +642,8 @@ In code mode, the selection needs to be prefixed with the
module."
"code")
(string= (treesit-node-type x)
"content")))))
- (is-symbol-p (assoc value typst-ts-editing-symbol-alist))
- (is-emoji-p (assoc value typst-ts-editing-emoji-alist))
+ (is-symbol-p (assoc value typst-ts-symbol-alist))
+ (is-emoji-p (assoc value typst-ts-emoji-alist))
(to-insert value))
(cond
((string= (treesit-node-type inside-code) "code")
diff --git a/typst-ts-faces.el b/typst-ts-faces.el
index 5f09186585..b3ea4e4110 100644
--- a/typst-ts-faces.el
+++ b/typst-ts-faces.el
@@ -256,19 +256,19 @@
"Face for math indicator $."
:group 'typst-ts-faces)
-;; code from Auctex
+;; code from Auctex
(defface typst-ts-superscript-face
'((t (:height 0.85)))
"Face used for superscripts."
:group 'typst-ts-faces)
-;; code from Auctex
+;; code from Auctex
(defface typst-ts-subscript-face
'((t (:height 0.85)))
"Face used for subscripts."
:group 'typst-ts-faces)
-;; code from Auctex
+;; code from Auctex
(defface typst-ts-script-char-face
(let ((font '(:inherit underline)))
`((((class grayscale) (background light))
diff --git a/typst-ts-misc-commands.el b/typst-ts-misc-commands.el
index 62af890114..0d469608cc 100644
--- a/typst-ts-misc-commands.el
+++ b/typst-ts-misc-commands.el
@@ -29,6 +29,7 @@
;; :group 'typst-ts)
(defun typst-ts-mc-install-grammar ()
+ "Install Typst grammar."
(interactive)
(let ((treesit-language-source-alist treesit-language-source-alist))
(add-to-list 'treesit-language-source-alist
@@ -37,6 +38,8 @@
(defun typst-ts-mc-export-to-markdown ()
+ "Export current file to markdown.
+Require pandoc to be installed."
(interactive)
;; for simplicity
@@ -57,14 +60,17 @@
(display-buffer buffer-name)))
(defun typst-ts-mc-search-typst-symbol ()
+ "Search typst symbols through website."
(interactive)
(browse-url "https://typst.app/docs/reference/symbols/sym/"))
(defun typst-ts-mc-recognize-typst-symbol ()
+ "Recognize hand-written symbols through website."
(interactive)
(browse-url "https://detypify.quarticcat.com/"))
(defun typst-ts-mc-search-package ()
+ "Search typst packages through website."
(interactive)
(browse-url "https://typst.app/universe"))
diff --git a/typst-ts-mode.el b/typst-ts-mode.el
index d21867798d..9d661b432c 100644
--- a/typst-ts-mode.el
+++ b/typst-ts-mode.el
@@ -32,6 +32,7 @@
(require 'treesit)
(require 'outline)
+(require 'elec-pair)
(require 'typst-ts-embedding-lang-settings)
(require 'typst-ts-core)
@@ -224,6 +225,8 @@ If you want to enable/disable specific font lock feature,
please change
(defun typst-ts-render-math-scripts-fn (node _override _start _end)
+ "Font lock function for math scripts.
+NODE: see `treesit-font-lock-rules'."
(let* ((ns (treesit-node-start node))
(ne (treesit-node-end node))
(prev-node-text (treesit-node-text (treesit-node-prev-sibling node)))
@@ -414,6 +417,7 @@ This function is meant to be used when user hits a return
key."
1)))
(defun typst-ts--indentation-prev-line-is-item-p (_node _parent _bol)
+ "Detect whether the previous line is a item."
(save-excursion
(forward-line -1)
(back-to-indentation)
@@ -551,7 +555,7 @@ typst tree sitter grammar (at least %s)!"
(current-time-string min-time))
;; add-function :override buffer-locally doesn't work, so we do this...
;; FIXME: Try and find a better way (maybe by changing electric-pair).
(remove-hook 'post-self-insert-hook
- 'electric-pair-post-self-insert-function t)
+ #'electric-pair-post-self-insert-function t)
(add-hook 'post-self-insert-hook
#'typst-ts-electric-pair-open-newline-between-pairs-psif
t))
diff --git a/typst-ts-variables.el b/typst-ts-variables.el
index 87b98b5c14..3d52ac6d55 100644
--- a/typst-ts-variables.el
+++ b/typst-ts-variables.el
@@ -136,8 +136,8 @@ is eliminated."
'(display-buffer-at-bottom
(window-height . fit-window-to-buffer))
"Display buffer parameters.
-Note that since the major mode of typst watch buffer is derived from
compilation
- mode. If you have a rule like `((derived-mode . compilation-mode) ...)' in
+Note that since the major mode of Typst watch buffer is derived from
compilation
+ mode. If you have a rule like \='((derived-mode . compilation-mode) ...)\='
in
your `display-buffer-alist', then this option will be covered by that rule."
:type 'symbol
:group 'typst-ts-watch)