nvarner / typst-lsp

A brand-new language server for Typst, plus a VS Code extension
MIT License
1.17k stars 74 forks source link

Local packages don't work #242

Closed SillyFreak closed 1 year ago

SillyFreak commented 1 year ago

Issue

(typst 0.6.0 information is just for the sake of completeness of the analysis. I observed the behavior in both versions, but of course only care about the latest one.)

I have installed a test package locally at ~/.local/share/typst/packages/local/template/0.0.1/ (typst 0.6.0: ~/.local/share/typst/packages/local/template-0.0.1/). In an example typst file, I have referred to two libraries like this:

#import "@preview/example:0.1.0": add
#import "@local/template:0.0.1": sub

#add(2, 7)

#sub(2, 7)

Running typst c test.typ compiles the file successfully, so I am confident that the local package is valid. However, the VSCode extension shows the error "package not found (searched for @local/template:0.0.1)" on the second line. Removing the local package reference (keeping the remote one) works.

Logs

Nothing illuminating; there's textDocument/publishDiagnostics with the message above, the compilation failure, and some events that I assume are pretty standard.

nvarner commented 1 year ago

For what it's worth, the Typst 0.6 implementation is actually wrong and looks in the same place as Typst 0.7. (I didn't notice I was developing off old documentation, and typst-lsp 0.8 was current for such a short time that I decided to leave it.)

I'll look into what could be causing this for typst-lsp v0.9, since that is a bug.

nvarner commented 1 year ago

It looks like I was using the wrong directory for local packages (~/.config/typst/packages/...). I'll make a fix for that now, which should be quick. Unless it's harder than I expect, the fix will appear in the next release.

SillyFreak commented 1 year ago

thanks! your plugin (and by extension the LSP) is great; this fix will help me putting off more important work for sure!

nvarner commented 1 year ago

Thanks for the error report! Glad to hear the project is helpful. And unfortunately, this fix is doing the same for me :)

It should be fixed in the next release.