starpls icon indicating copy to clipboard operation
starpls copied to clipboard

Support for multi-workspaces mode

Open sluongng opened this issue 1 year ago • 2 comments

We have a user with a setup where they would open VSCode in a "workspace mode" and in that workspace, there are several different Bazel projects.

For example:

parent/
parent/bazel-proj1/
parent/bazel-proj2/

when opened in this mode, starpls does not work.

It seems like it failed to detect the Bazel project's root dir, which could be detected by running bazel info workspace inside the same dir as the file being opened.

sluongng avatar Apr 23 '24 17:04 sluongng

Currently have some work in progress for this feature!

But maybe a clarifying question to help me move forward - is it expected that the nested repositories inherit configuration for files like .bazelrc, .bazelversion, etc. from the root workspace, or do the nested repositories have their own sets of those files? I saw that in https://github.com/bazelbuild/vscode-bazel/issues/383 sometimes that the expected behavior from the end user is that the nested repositories inherit configs from these files, even though I don't think Bazel actually does this by default, so maybe we'd need some custom logic on the LSP side to handle this if it's desired behavior

withered-magic avatar Apr 23 '24 19:04 withered-magic

I don't think there is a use case for a "workspace-level" config like that. We should simply follow the WORKSPACE detection logic of Bazelisk https://github.com/bazelbuild/bazelisk/blob/24651abd7c833829b585373cd540a30cd98e7dfd/ws/ws.go#L9-L34

Once Bazelisk has downloaded the appropriate bazel version, then just run bazelisk info workspace to determine the setting.

Users could always override their .bazelrc via $HOME/.bazelrc and/or /etc/bazelrc and/or an explicit --bazelrc flag

sluongng avatar Apr 24 '24 07:04 sluongng