-
Notifications
You must be signed in to change notification settings - Fork 76
Conversation
Great work! I wonder, is there a way to add a context menu button to .typ files so that you can right-click them and select "Pin file" or something? That would be interesting... (But also not strictly necessary for this PR) |
@PgBiel I think this abstraction is mostly used by editor scripts. Therefore, you don't have to pin them manually, but with some configuration on your favorite editor. For example, I made a branch in typst-preview, which invokes "typst-lsp.pinMainToCurrent" when it starts to preview some file, https://github.com/Enter-tainer/typst-preview/tree/pin-lsp. There is also a configurable switch to enable/disable it, determined by users. I believe neovim users may invent other luascript like it. Your idea also looks great to me, since it is much more convenient than keystroking ctrl+shift+p and running "typst-lsp.pinMainToCurrent" command. But honestly, we may leave it for another PR to reduce code changes, because I'm dumb and currently don't know how to bind it 😃. I want to say that it is expected to leave many space for user customization. And we may discuss and equip lsp with more smart behaviors in future. |
Awesome. We can definitely investigate that in the future. Thanks for the great work 👍 |
Looks great! I think this would solve #366. I personally think it would be great to expose a configuration option such as |
@SimonRask Note that the typst-lsp program provides Since I don't use helix, it would be appreciate if you can verify it that current PR can work in helix by some way.
Now we may have two extra features in summary:
|
Sorry for the confusion. I meant
I will try to see if I can somehow pass arguments to
Agreed |
I'm not fully satisfied with this solution, but this is a big improvement over the status quo. I'll merge for now. Thank you! |
@nvarner should we create a tracking issue? For discussion on other perfect solutions or improving this solution. |
This PR proposes an abstraction corresponding to "Preview this file" in official webapp. In conclusion, this PR adds a "typst-lsp.doPinMain" command to lsp program which could then get used by:
Usage 1: improve mode of exportPDF by adding "onPinnedMain{Save,Type}".
Currently, automatically exportPDF on save or on type is annoying since typst-lsp cannot identify the source files that has empty content. This PR can allow users only exporting PDF "onPinnedMain{Save,Type}", close #11, may close #184, may close #285.
Usage 2: make hover tip and autocompletion according to the pinned file.
Before, hover variable in template.typ doesn't work at all:
After, it shows result correctly:
Usage 3: show diagnostics according to compilation of the pinned file when editing other files, close #153.
Before, the errors in thesis.typ fly away if the user doesn't focus thesis.typ:
After, lsp will show diagnostics according to compilation of the pinned file when editing template.typ:
Usage 3.5: eliminate false errors in a project with multiple files.
Note that lsp may also produces false errors, such as errors on bib things. Once this PR is ready, editors could pin the main file in a project with multiple files, may close #64, may close #366.