chomosuke / typst-preview.nvim

Low latency typst preview for Neovim
GNU General Public License v3.0
254 stars 16 forks source link

Add `get_main_file` function #4

Closed pabloavi closed 5 months ago

pabloavi commented 10 months ago

We have a project tree:

project_root
├── master.typ
├── subfile_1.typ
├── subfile_2.typ
├── ...
└── template.typ

Currently, one has to enter the main file of a project, run :TypstPreview and open the included subfile in order to edit it and preview the project. However, if one opens a subfile (that does not import template, etc.), it just previews it, not the whole project, which contains all the contents, template...

Ideally, there should be a get_main_file function, similar to get_root, that is user-defined and returns the file that should be preview, so that each user can decide what the main file of a project is. That way, when :TypstPreview or alternative commands are used, they create the preview of the whole project, as it is based on the master file that includes the subfiles.

chomosuke commented 10 months ago

Hi,

I acknowledge that this is a desirable feature. However, currently the preview is entirely tied to the life time of the buffer. When the buffer is unloaded, the preview is shut down. And when there are multiple preview going on at the same time, they are index by their buffer number. While implementing this certainly wouldn't be hard. It wouldn't be trivial either, and I certainly don't have any time to do this anytime soon sorry.

I would be happy to review and accept any pull request though :).