branch: elpa/typst-ts-mode
commit 879665683e11ab318419a53e416d1624655a6c76
Author: Ziqi Yang <[email protected]>
Commit: Ziqi Yang <[email protected]>
feat: add more fontification rules for markup
---
.gitignore | 2 ++
typst-ts-mode.el | 44 +++++++++++++++++++++++++++++++++++---------
2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..e1f2ee5410
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.elc
+highlight.compare.scm
\ No newline at end of file
diff --git a/typst-ts-mode.el b/typst-ts-mode.el
index cc9d0eb149..daa679ce25 100644
--- a/typst-ts-mode.el
+++ b/typst-ts-mode.el
@@ -95,16 +95,42 @@
:height ,(nth 5 typst-ts-markup-header-scale)))
"See `typst-ts-markup-header-face'.")
+(defface typst-ts-markup-url-face
+ '((t :inherit font-lock-string-face))
+ "Face for url."
+ :group 'typst-ts-markup)
+
+(defface typst-ts-markup-emphasis-face
+ '((t :slant italic))
+ "Face for emphasis."
+ :group 'typst-ts-markup)
+
+(defface typst-ts-markup-strong-face
+ '((t :weight bold))
+ "Face for strong."
+ :group 'typst-ts-markup)
(defvar typst-ts-mode-font-lock-rules
'(;; Typst font locking
:language typst
:feature comment
- '((comment) @font-lock-comment-face)
+ ((comment) @font-lock-comment-face)
:language typst
:feature markup
- '((heading) @)))
+ ((heading) @typst-ts-markup-header-face
+ (url) @typst-ts-markup-url-face
+ (emph) @typst-ts-markup-emphasis-face
+ (strong) @typst-ts-markup-strong-face
+ ;; (item) @typst-ts-markup-item-face ;; TODO
+ ;; (term) @typst-ts-markup-term-face ;; TODO
+ ;; (symbol) @typst-ts-markup-symbol-face ;; TODO
+ ;; (shorthand) @typst-ts-markup-shorthand-face ;; TODO
+ ;; (quote) @typst-ts-markup-quote-face ;; TODO
+ ;; (align) @typst-ts-markup-align-face ;; TODO
+ ;; (letter) @typst-ts-markup-letter-face ;; TODO
+ ;; (linebreak) @typst-ts-markup-linebreak-face ;; TODO
+ )))
(defun typst-ts-mode-comment-setup()
"Setup comment related stuffs for typst-ts-mode."
@@ -143,16 +169,16 @@
(apply #'treesit-font-lock-rules typst-ts-mode-font-lock-rules))
(setq-local treesit-font-lock-feature-list
;; TODO
- '((comment markup)
- (markup code)
- (builtin)
- (operator ponctuation)
+ '((markup comment)
+ ;; (markup code)
+ ;; (builtin)
+ ;; (operator ponctuation)
;; (bracket delimiter error function operator property
variable)
))
-
- (add-to-list 'auto-mode-alist '("\\.typ\\'" . typst-ts-mode))
-
(treesit-major-mode-setup))
+;;;###autoload
+(add-to-list 'auto-mode-alist '("\\.typ\\'" . typst-ts-mode))
+
(provide 'typst-ts-mode)