Myriad-Dreamin / tinymist

Tinymist [ˈtaɪni mɪst] is an integrated language service for Typst [taɪpst].
https://myriad-dreamin.github.io/tinymist
Apache License 2.0
278 stars 11 forks source link

Fail to recognize bib items when multiple files involve #321

Closed Devin-Yeung closed 4 weeks ago

Devin-Yeung commented 1 month ago

Describe the bug

Tinymist fail to identify the bib items when multiple files involves. For example, if #bibliography("ref.bib") is in main.typ and content.typ is #include by main.typ, the bib items are only available in main.typ but not available in content.typ.

Package/Software version:

VSCode version(Help -> About):

Version: 1.89.0 (Universal)
Commit: b58957e67ee1e712cebf466b995adf4c5307b2bd
Date: 2024-05-01T02:10:10.196Z (1 mo ago)
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin arm64 23.0.0

tinymist extension version: v0.11.10. Get it by tinymist --version in terminal.

tinymist
Build Timestamp:     2024-05-26T03:55:31.206765000Z
Build Git Describe:  v0.11.10
Commit SHA:          eb12ef0671adb1e1e09e6e99facbfa46f96a6ed7
Commit Date:         None
Commit Branch:       None
Cargo Target Triple: aarch64-apple-darwin
Typst Version:       0.11.1

Additional context

Here are the steps to reproduce the bug:

directory structure:

.
├── ref.bib
├── content.typ
├── main.typ

Source code for ref.bib

@phdthesis{madje2022typst,
  title  = {A Programmable Markup Language for Typesetting},
  author = {M{\"a}dje, Laurenz},
  year   = {2022},
  school = {2022}
}

Source code for main.typ

// main.typ
#include "content.typ"
#bibliography("ref.bib", full: true)

Source code for content.typ

// content.typ
@madje2022typst // lsp gives an error: label `<madje2022typst>` does not exist in the document
Myriad-Dreamin commented 4 weeks ago

You need to pin the main file so that the entry file doesn't change when you switch files.

Hint: typst-preview supports to pin it when you start to preview some file. https://github.com/Enter-tainer/typst-preview/blob/main/addons/vscode/package.json#L224

Devin-Yeung commented 4 weeks ago

You need to pin the main file so that the entry file doesn't change when you switch files.

This works for me, thank you! Btw, I am curious about how can I achieve this if I use other editors (e.g Zed / neovim) which does not support typst-preview. Does tinymist provide any option to pin the main file?

Myriad-Dreamin commented 4 weeks ago

You need to pin the main file so that the entry file doesn't change when you switch files.

This works for me, thank you! Btw, I am curious about how can I achieve this if I use other editors (e.g Zed / neovim) which does not support typst-preview. Does tinymist provide any option to pin the main file?

No common best model currently, they can set an entry file by configuration globally or in workspace, https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/vscode#passing-extra-cli-arguments. VSCode and neovim users can also invoke pin commands, but this doesn't work if clients don't have well support to lsp commands, like helix or zed. https://github.com/Myriad-Dreamin/tinymist/tree/main/editors/vscode#working-with-multiple-file-projects

Devin-Yeung commented 4 weeks ago

Thank you for your time answering this, I think I can mark this issue as solved