typst-lsp icon indicating copy to clipboard operation
typst-lsp copied to clipboard

non-typst files not being recached when changed

Open jonaspleyer opened this issue 2 years ago • 10 comments

  • Component:
    • [x] VSCode Extension
    • [ ] VSCodium Extension
  • Extension version: 0.4.1
  • OS version and name:
$uname -a
Linux manjaro 5.17.15-1-MANJARO #1 SMP PREEMPT Wed Jun 15 07:09:31 UTC 2022 x86_64 GNU/Linux
  • [x] I am on the latest stable version of the extension/LSP.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.

Issue

Non-capitalized citation keys throw errors. Consider this MWE:

$mwe.typ
Citing einstein @einstein1916
bibliography("mwe.bib")
$mwe.bib
@article{einstein1916,}

When capitalizing einstein1916 to Einstein1916 no error is thrown. This error unfortunately prohibits the extension from compiling (eg. upon save), however but the compiler will still successfully execute and generate the document from the command line.

Logs

VSCode logs:

label does not exist in the document

jonaspleyer avatar Apr 20 '23 18:04 jonaspleyer

That's strange. What version of the Typst command line are you using?

nvarner avatar Apr 20 '23 20:04 nvarner

I am running 1:0.1.0-1 which is the latest version.

$pacman -Qi typst
Name            : typst
Version         : 1:0.1.0-1
Description     : A markup-based typesetting system for the sciences
Architecture    : x86_64
URL             : https://typst.app
Licenses        : Apache
Groups          : None
Provides        : None
Depends On      : None
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 18,10 MiB
Packager        : Caleb Maclennan <[email protected]>
Build Date      : Mi 05 Apr 2023 17:39:53 CEST
Install Date    : Do 20 Apr 2023 13:34:22 CEST
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

jonaspleyer avatar Apr 20 '23 22:04 jonaspleyer

Okay I just tried something else and there seem to be multiple situations in which the problem can be reproduced. I believe it may have something to do with internal state of the extension. For example the MWE above will work if I reload the extension.

This example works just fine if I either start VSCode fresh or reload the extension. It will also work fine if it is capitalized.

$mwe.typ
Citing einstein @einstein1916
bibliography("mwe.bib")
$mwe.bib
@article{einstein1916,}

However, if i change only my bib-file to the following it will still work (if I do not reload Extension/VSCode).

$mwe.bib
@article{Einstein1916,}

it seems to me that the keys or the whole bibliography are being stored intermediately by the extension and not updated when changing the bib-file. In contrast, the CLI will reload the new bib-file and throw an error if I supply the second example. Reloading the extension or VSCode will correctly throw an error as described above. Simply reloading the document (closing and opening again) will not resolve the problem.

Note: I have changed the title of the bug.

jonaspleyer avatar Apr 21 '23 10:04 jonaspleyer

That makes more sense. You are right that non-Typst files (including .bib files) are cached once, but should not be.

nvarner avatar Apr 21 '23 20:04 nvarner

I can confirm this happens for images with typst-lsp 0.5.1 (vscode, configured to use system typst 0.4.0). compiling manually updates the images, but on the next save they revert to the previous state after auto-compiling

classabbyamp avatar Jun 07 '23 23:06 classabbyamp

hi, I'm not sure the issue is fixed, I'm using the master branch and still have this issue I think.

I am using this lsp with helix, the recompile on save works quite well. However it seems that the bibliography file is not reloaded on save? I use zotero with the auto export from better biblatex so that my bib file stays up to date, however the lsp cannot find refs added after opening the document. I have to close the document and reopen it for new entries to be detected. (i.e. restart the lsp basically)

alxsimon avatar Jul 08 '23 19:07 alxsimon

I just came across this as well. Any entries added to the .bib file while the typst file is open in VSCode cannot be cited in the typst file, in fact they appear as label errors and prevent the file from compiling. I'm using version 0.12.1.

willismonroe avatar Jan 04 '24 16:01 willismonroe

I just came across this as well. Any entries added to the .bib file while the typst file is open in VSCode cannot be cited in the typst file, in fact they appear as label errors and prevent the file from compiling. I'm using version 0.12.1.

Hi, how did you edit the bib file? if you edit it in vscode and it doesnt get updated, i think it is a bug.

Enter-tainer avatar Jan 04 '24 16:01 Enter-tainer

Ah, now that I think about it, it might be more complicated. My .bib file is auto-exported from Zotero.

However, I import my bibliography using a local package. Which means that the local package is referencing a symlinked version of my bibliography (stored elsewhere). I wonder if this is obscuring the file change and thus not invalidating the cache?

willismonroe avatar Jan 04 '24 16:01 willismonroe

Ah, now that I think about it, it might be more complicated. My .bib file is auto-exported from Zotero.

I think this might be a (known) problem now. currently typst-lsp cannot track edits that happens out of vscode.

Enter-tainer avatar Jan 04 '24 16:01 Enter-tainer