zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
39.55k stars 2.06k forks source link

support for Typst language #12088

Open gabrielalexandrelopes opened 1 month ago

gabrielalexandrelopes commented 1 month ago

Check for existing issues

Describe the feature

Support for the Typst language (to replace LaTeX): https://github.com/typst/typst, with instant preview, like in the VSCode plugin: https://marketplace.visualstudio.com/items?itemName=mgt19937.typst-preview

The Typst compiler is written in rust, so it could be a nice integration.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

bbb651 commented 1 month ago

There's already an extension which should already be available in Zed (which uses tinymist, which seems more active and with more features than typst-lsp). I previously tried to make one based on typst-lsp before extensions had lsp support: #9152 but it's a lot worse than WeetHet's one. Pdf preview is quite hard to do, I had a discussion on possible ways to implement it here (the vscode extension uses pdf.js but Zed currently doesn't have for support webviews), to summarize it:

But I just found out that typst has png and svg support which would be a lot easier to implement (doesn't replace the need for pdf support, but is a good workaround). The issue is that extensions currently can't really run code other than tree-sitter grammars/lsp, and this would need a custom view, so it's blocked on more extension support: #5269

gabrielalexandrelopes commented 1 month ago

Thank you for your answer! Indeed using a web view would make this extension very easy to implement using e.g. https://github.com/Myriad-Dreamin/typst.ts.

The PNG idea is good, I tried typst watch test.typ test.png which compiles on save, but unfortunately the PNG does not update in zed (https://github.com/zed-industries/zed/issues/11529)

bbb651 commented 1 month ago

If/when webviews are implemented I don't even think typst.ts is necessary, we can just run the normal typst binary in watch mode and have pdf implemented with webviews separately. I'll try to work on implementing refreshing in image views, I completely overthought it with the custom view thing, I forgot you can just... view pngs 😅

WeetHet commented 1 month ago

Hi! I'm the author of the typst extension. Honestly, I'm not using it right now, as there isn't a way to monitor typing events from the extension and zed doesn't have autosave on delay. I thing that, until one of those features (hopefully, input monitoring) lands in zed for extensions, you are better of using neovim with tinymist and the typst-preview plugin