typst-lsp
typst-lsp copied to clipboard
Cannot import .typ file from outer folder in workspace of VSCode anymore.
-
Component:
- VSCode Extension
- Extension version: 0.9.4
- LSP version: 0.9.4
- OS version and name: macOS 13.5 Ventura
- I am on the latest stable version of the extension/LSP.
- I have searched the issues of this repo and believe that this is not a duplicate.
Issue
Logs
Cannot import .typ file from outer folder in workspace of VSCode anymore after update to 0.9+.
[Error - 3:10:35 AM] src/server/lsp.rs:246 { message = could not handle source save;
err = failed to generate document after compilation;
uri = file://~/Documents/book-linear-algebra/09-%E5%87%A0%E4%BD%95%E5%8F%98%E6%8D%A2.typ; }
Were you on 0.7 or earlier before updating to 0.9? If so, I think this is an (admittedly inconvenient) intentional behavior of Typst to keep files from importing other files outside the current package: https://github.com/typst/typst/issues/1664#issuecomment-1622395258
In the LSP, root
is set based on your open workspace folders. If you open the parent directory, I think this will work as you expect. Alternatively, make typst-styles
a local package. If those fixes don't work, or you were already running 0.8 or 0.9, then this is a bug.
I updated typst and typst-lsp at the same time, so I am not sure which this bug is for. My codes worked well before the update.
I guess you are right, it's due to how --root
treating the path. I probably have to accept your suggestion though I am reluctant to make my template as a local package because more than 5 folders are using it, and it contains multiple files.
I tried to compile using CLI, but it says error: input file must be contained in project root.
. It seems this bug is on the typst side.
Hello again, @nvarner. Could you please consider adding a --root
option in the VSCode Extension?
@ivaquero https://github.com/nvarner/typst-lsp/blob/fc6af7505cd48e4fe4fefaef9bac73aa64d05369/editors/vscode/package.json#L39-L47 Does this option help?
Thank you so much! @Myriad-Dreamin. I misunderstood the rootPath
.
I tried to set "typst-lsp.rootPath": ".."
or "typst-lsp.rootPath": ${HOME}/Documents
, but it still doesn't work. Is the rootPath
option is in accordance with --root
in the CLI? For the CLI, typst compile --root=".."
works well.
I just tried adding "typst-lsp.rootPath": "/",
to my settings.json and it seems not to respect the change.
Same issue
same issue as well, also tried setting my TYPST_ROOT env-var but that doesn't seem to work either