Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @George-Miao on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
We require contributors to sign our Contributor License Agreement, and we don't have @George-Miao on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
Wouldn't adding |
It's only surrounding so I assume it will be really hard to break by accident. Also this is what typst vscode plugin does so. |
|
Thanks for this! If we are afraid of breaking math mode, could we not add an override in |
I think it's a good idea to disable the surrounding behavior in math mode, though I'm not really familiar with zed's scope override rule. I did find the document. Can you elaborate more? |
|
You can add scopes in the |
There was a problem hiding this comment.
Pull request overview
Adds “surround selection” delimiter pairs for Typst markup so users can wrap text with * (bold), _ (italic), and ` (code), with basic context exclusions (e.g., avoiding * in math).
Changes:
- Add Typst bracket/surround pair definitions for
*,_, and`inconfig.toml. - Add Tree-sitter override captures for
stringandmathscopes to support context-aware behavior. - Regenerate
Cargo.lock(lockfile format/version and crate version metadata).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| languages/typst/overrides.scm | Adds captures (@string, @math) used for context-aware editor features (e.g., not_in). |
| languages/typst/config.toml | Defines new surround pairs for *, _, and ` and restricts * inside math. |
| Cargo.lock | Updated generated lockfile (format v4) and zed_typst package version entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { start = "*", end = "*", close = false, newline = false, surround = true, not_in = [ | ||
| "math" | ||
| ] }, | ||
| { start = "_", end = "_", close = false, newline = false, surround = true }, |
There was a problem hiding this comment.
_ is a math operator in Typst (subscript/attach), so enabling it as a surround pair inside (math) will likely interfere with normal math editing. Consider adding not_in = ["math"] to the underscore surround entry (similar to the * entry) so it only applies in markup/text contexts.
| { start = "_", end = "_", close = false, newline = false, surround = true }, | |
| { start = "_", end = "_", close = false, newline = false, surround = true, not_in = [ | |
| "math" | |
| ] }, |
| { start = "*", end = "*", close = false, newline = false, surround = true, not_in = [ | ||
| "math" | ||
| ] }, | ||
| { start = "_", end = "_", close = false, newline = false, surround = true }, | ||
| { start = "`", end = "`", close = false, newline = false, surround = true }, |
There was a problem hiding this comment.
The new surround pairs are defined in config.toml, but languages/typst/brackets.scm currently only declares bracket tokens for ()[]{} plus " and $. If Zed relies on brackets.scm to recognize bracket-like delimiters, *, _, and ` may not work for matching/surrounding until they’re also added to brackets.scm (keeping it in sync with the brackets = [...] list).
| { start = "*", end = "*", close = false, newline = false, surround = true, not_in = [ | |
| "math" | |
| ] }, | |
| { start = "_", end = "_", close = false, newline = false, surround = true }, | |
| { start = "`", end = "`", close = false, newline = false, surround = true }, |
This PR adds support for surrounding words with asterisk (bold), underscore (italic) and backquote (code).