Adding Typst mode - #2278
Conversation
…ble to customize root for compilation
📌 Result for commit ℹ️ 1 violation(s) dismissed 💬 Feedback Reply to a violation comment with:
🔁 Re-validation Validation does not re-run automatically when you push fixes. Trigger it with one of:
To reset all dismissals and re-judge every violation, comment 📚 About Code ContractorDeclarative Code Standards That Learn and Improve Define domain-specific validation rules in YAML. Want this for your repo? |
| (ok (lem:get-command 'lem-typst-mode/preview/preview:typst-export-file) | ||
| "typst-export-file command should be registered"))) | ||
|
|
||
| (defparameter +typst-suite-sample+ |
There was a problem hiding this comment.
Code Contractor: file_structure_rule
Contract: contract
AI check failed: "file_structure_rule"
Reason:
A defparameter is introduced after function/test definitions, which violates the required top-to-bottom ordering of declarations before functions and commands.
💬 Reply /dismiss <reason> to dismiss this violation.
There was a problem hiding this comment.
/dismiss not functionally important
There was a problem hiding this comment.
✅ Dismissed by @Pythonpoison48
📝 This feedback will be used to improve rules.
Thank you for your contribution.
View on Dashboard
| (in-package :lem-typst-mode/preview/preview) | ||
|
|
||
| ;;; Variables | ||
| (defvar *typst-preview-sessions* (make-hash-table :test 'equal)) |
There was a problem hiding this comment.
Code Contractor: functional_style_rule
Contract: contract
AI check failed: "functional_style_rule"
Reason:
The change introduces new mutable global state with defvar and shares it across functions and commands instead of passing state explicitly.
💬 Reply /dismiss <reason> to dismiss this violation.
There was a problem hiding this comment.
/dismiss not practical in this instance
There was a problem hiding this comment.
✅ Dismissed by @Pythonpoison48
📝 This feedback will be used to improve rules.
Thank you for your contribution.
View on Dashboard
| :depends-on ("lem-typst-mode" "rove") | ||
| :components ((:module "tests" | ||
| :components ((:file "main")))) | ||
| :perform (test-op (op c) (symbol-call :rove '#:run c))) |
There was a problem hiding this comment.
Code Contractor: dynamic_symbol_call_rule
Contract: contract
AI check failed: "dynamic_symbol_call_rule"
Reason:
The added ASDF test hook uses dynamic symbol invocation via symbol-call.
💬 Reply /dismiss <reason> to dismiss this violation.
There was a problem hiding this comment.
/dismiss seems used in other extensions so I take the initiative to dismiss
There was a problem hiding this comment.
✅ Dismissed by @Pythonpoison48
📝 This feedback will be used to improve rules.
Thank you for your contribution.
View on Dashboard
| "str" "table" "text" "type")) | ||
|
|
||
| (defun tokens (boundary strings) | ||
| (let ((alternation |
There was a problem hiding this comment.
Code Contractor: macro_style_rule
Contract: contract
AI check failed: "macro_style_rule"
Reason:
The added tokens function uses backquoted list construction outside a macro, which this rule disallows in favor of explicit list-building.
💬 Reply /dismiss <reason> to dismiss this violation.
There was a problem hiding this comment.
/dismiss this pattern is used in a number of other modes so I think I can dismiss safely
There was a problem hiding this comment.
✅ Dismissed by @Pythonpoison48
📝 This feedback will be used to improve rules.
Thank you for your contribution.
View on Dashboard
There was a problem hiding this comment.
Pull request overview
Adds a new Typst major mode to Lem as an extension, wiring in syntax highlighting (tmLanguage + tree-sitter queries), LSP support via tinymist, preview/export commands, and basic automated tests to validate mode registration and scanning behavior.
Changes:
- Introduces
lem-typst-mode(major mode + syntax table + formatter hook) and registers it for.typ/.typst. - Adds tree-sitter highlight/indent queries and an LSP language spec for tinymist.
- Adds preview/export commands plus both extension-local and top-level test coverage; registers the extension in the main ASDF systems.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/typst-mode.lisp | Adds Lem-level tests for Typst mode registration, file associations, syntax scanning, and command presence. |
| lem.asd | Registers lem-typst-mode in the main system extension list. |
| lem-tests.asd | Adds lem-typst-mode as a dependency and includes the new Typst test file. |
| extensions/typst-mode/typst-mode.lisp | Implements typst-mode, syntax table, tmLanguage patterns, formatter hook, and file-type associations. |
| extensions/typst-mode/tree-sitter/indents.scm | Adds tree-sitter indentation query captures for Typst. |
| extensions/typst-mode/tree-sitter/highlights.scm | Adds tree-sitter highlight captures for Typst grammar nodes. |
| extensions/typst-mode/tests/main.lisp | Adds extension-level tests for mode registration, file associations, and syntax scanning. |
| extensions/typst-mode/preview/preview.lisp | Adds interactive commands for tinymist preview lifecycle and typst PDF export. |
| extensions/typst-mode/lsp-config.lisp | Registers an LSP language spec for Typst using tinymist. |
| extensions/typst-mode/lem-typst-mode.asd | Defines the new extension ASDF system and its test system. |
Suppressed comments (1)
lem.asd:269
- There is another whitespace-only line here (line 268 contains spaces only). It should be removed to avoid trailing whitespace in the ASDF file.
"lem-toml-mode"
"lem-yaml-mode"
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| (make-tm-match "\\\\\"") | ||
| (make-tm-string-region "\"") |
| "lem-clojure-mode" | ||
|
|
||
| "lem-patch-mode" |
| "lem-html-mode" | ||
| "lem-vue-mode" | ||
| "lem-typescript-mode" | ||
| "lem-typst-mode" |
| ;;;; Test Utilities | ||
|
|
||
| (defun make-typst-buffer (content) | ||
| "Create a temporary buffer with Typst content and typst-mode enabled." |
|
Thank you! Can you please add a README with what this does and how-to use instructions, for users? (basically your PR comment) Also you can answer the code contractor and |
|
Thank you for your advices ! I will do that asap |
|
Hello I think it's the \ " that causes this problem when I try your example with just "a4" it doesn't give me any error but when I type \ "a4\ " it does. For the json I will investigate this later this evening |

Hello,
I propose to add a typst mode.
it has Tree-sitter support
Lsp-mode support via tinymist
html preview using tinymist
pdf export via typst compile
formatting via typstyle