Open davidovich opened 1 year ago
Can you find imports if you enable the "resolve paths with Tanka" option? I don't have any jpaths set for any of my repositories
Well, that improves it for folder relative lib
and vendor
. Nice. But build
is still ignored. In the current project, I am on bare jsonnet, not tanka (unfortunately at the moment).
@julienduchesne
Also running into this exact issue.
<my_workspace>/.vscode/settings.json
{
"jsonnet.languageServer.jpath": [
"/${workspaceFolder}/configs/foo/bar/"
],
"jsonnet.languageServer.tankaMode": false,
}
and the resulting debug jsonnet language server output
level=info msg="configuration updated: {ResolvePathsWithTanka:true JPaths:[] ExtVars:map[] ExtCode:map[] FormattingOptions:{Indent:2 MaxBlankLines:2 StringStyle:1 CommentStyle:1 PrettyFieldNames:true PadArrays:false PadObjects:true SortImports:true UseImplicitPlus:true StripEverything:false StripComments:false StripAllButComments:false} EnableEvalDiagnostics:true EnableLintDiagnostics:false}"
ResolvePathsWithTanka and JPaths are both incorrect.
When I add these settings to my global user settings, it works, but the workspace settings completely fails.
Adding to my about comment, appears like https://stackoverflow.com/questions/65192859/for-workspace-getconfiguration-how-do-i-get-a-setting-from-the-multi-root-works addresses how to fix this. When you access the configuration:
this:
const workspaceConfig = workspace.getConfiguration('jsonnet');
changes to:
const uri = vscode.window.activeTextEditor.document.uri;
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
const workspaceConfig = workspace.getConfiguration('jsonnet', workspaceFolder);
Have not tested this at all, and possibly a null check is needed or a try catch that reverts back to the global settings.
Problem
When you use multiple folders in a VSCode workspace, the jpath is constructed with first workspace folder.
I have many jsonnet folders that respect a general hierearchy, and they are all in a named workspace.
I set my jpath to
[vendor, lib, build]
, but my libsonnet files are still not found, if I am not in the first folder.Browsing through the code, I see that only the first project is used to deduce an absolute jpath. Also, this seems to happen on start of client, and on config reload. This seems like a global setting sent to the language server...
Expectation
I would expect hat the configured jpath is relative to the current folder of the current workspace and that the extension use the current context to find my files.
Notes
Maybe we could use the
asRelativePath
function of the workspace API, orgetWorkspaceFolder
to deduce the correct jpaths.