grafana / grafana/vscode-jsonnet

Support multi-root workspaces

Open
#24 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
86
Forks
12
PR merge metrics
No merged PRs in 30d

Description

Problem
---------

When you use multiple folders in a VSCode [workspace](https://code.visualstudio.com/docs/editor/workspaces), 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.

```bash
# foreach folder of the workspace

vendor/ # as produced by jsonnet bundler
lib/ # local libraries
build/ # some generated json files for import
```

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](https://github.com/grafana/vscode-jsonnet/blob/main/src/extension.ts#L117) is used to deduce an absolute jpath. Also, this seems to happen on start of client, and on [config reload](https://github.com/grafana/vscode-jsonnet/blob/main/src/extension.ts#L163). 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](https://code.visualstudio.com/api/references/vscode-api#workspace), or `getWorkspaceFolder` to deduce the correct jpaths.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/extension.ts at the jpath handling around lines 117 and 163, then review the VS Code workspace APIs mentioned in the issue, especially asRelativePath and getWorkspaceFolder. Trace how the configured jpath becomes an absolute path for the language server. Done means jpath entries resolve correctly for the current folder across multi-root workspaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, vscode
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.