An Emacs major mode for typst, a markup-based typesetting system.
external executable: typst (least version: typst 0.1.0 (1c324765)
, which has typst compile
subcommand)
Emacs package: polymode (if you use straight
, it will automatically download this requirement for you)
Minimum Emacs version hasn’t been tested
(use-package typst-mode
:straight (:type git :host github :repo "Ziqi-Yang/typst-mode.el"))
;; push typst-mode directory to the load-path like this
(push (expand-file-name "modules/languages/typst-mode" user-emacs-directory) load-path)
;; load tyspt-mode
(require 'typst-mode)
typst-compile
(default bind:C-c C-c
; also providetypst-compile-preview
)typst-preview
(default bind:C-c C-p
)typst-toggle-watch
(default bind:C-c C-w
; also providetypst-watch
andtypst-stop-watch
)
feature | support | Example |
---|---|---|
Paragraph break | ✓ | |
Strong emphasis | ✓ | strong |
Emphasis | ✓ | emphasis |
Raw text | inline | `print(1)` |
Link | ✓ | https://typst.app/ |
Label | ✓ | <intro> |
Reference | ✓ | @intro |
Heading | ✓ | == Heading= |
Bullet list | ✓ | - item |
Numbered list | ✓ | + item |
Term list | ✓ | / Term: description |
Math | $x^2$ | |
Line break | ✓ | \ |
Smart quote | ‘single’ or “double” | |
Symbol shorthand | ~, — | |
Code expression | name | #rect(width: 1cm) |
Character escape | ✓ | Tweet at us \#ad |
Comment | ✓ | /* block */, // line |
Math inside pair of $
notation.
Currently not supported
Supported.
faces and custom variables with prefix typst
or typst-mode
- [ ] fix math mode
- [ ] add treesit mode
- [ ] show compile errors at real time when in Typst
watch
mode
For those stuffs cannot be done in short future.
- no syntax support for the context block
[ ]
which is located in the code block{ }
this problem possibly can be solved with nested polymode. However, currently there is no official support for this function? - indentation in the first line of code mode(contents between ‘{’ and ‘}’) may not works well, like this:
(hitting `tab` to indent has problem, but it works well when directly call `typst-mode-indent-line`)begin_code { [ // wrong indentation [ // indentation works well ] ] }
The issue may caused by Polymode. I have created an issue here: polymode/polymode#328