vscode-swift
vscode-swift copied to clipboard
Could not find /path/to/Package.swift in the workspace
I've installed the extensions and provided path to the latest language server built from master, but I'm getting an error every few seconds
[Error - 13:52:49] Request textDocument/completion failed.
Message: Could not find /path/to/Package.swift in the workspace.
Code: -32099
but the Package.swift file is right there. I used a slightly newer version of Swift toolchain than mentioned in prerequisities though, I used 4.0.2 (swiftlang-900.0.69.2 clang-900.0.38) instead of 4.0
Running into the same error. My guess (without knowing too much about how vscode-swift works) is that it's blindly asking sourcekit for cursor info for Package.swift, while it is a swift file, it defines the package rather than being part of the package.
I think you are right @strangemonad. Now how to solve this?
I think the best way is to make the language-server smarter. Though in what way is not immediately clear to me.
Possibly just disable the extension for Package*.swift
files in the root of the workspace?
Without digging in more, that might be too aggressive (from what I know so far of SourceKit). I think you still want syntax parsing / highlighting of Package.swift (as it is a swift file) but you don't want to query the SPM-aware "oracle" with cursor position since it's not part of the package (per SPM's view of the world). Yet you still want basic completion, documentation quick-view and pop-ups showing type signatures of the Package related types.
Basically, I think the fix is a larger one. You almost need some sense of a parallel instance of sourcekit which loads Package.swift on its own (assuming it depends on Swift and SPM only) and then the other sourckit root configured based on the package dependencies. Both of these would require work to make the language server "SPM-aware".
I don't want to commit my juuust yet because I'm not sure how much I'll have but I'm tempted to dig into this a bit more
FWIW not even Xcode tries to give you completion inside of Package.swift
:rofl:
Basically, I think the fix is a larger one. You almost need some sense of a parallel instance of sourcekit which loads Package.swift on its own (assuming it depends on Swift and SPM only) and then the other sourckit root configured based on the package dependencies.
That is an intriguing solution. :thinking: