Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show multi-root workspace warning as progress instead #2879

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 42 additions & 26 deletions vscode/src/rubyLsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ export class RubyLsp {
workspaceFolder: vscode.WorkspaceFolder,
eager: boolean,
) {
const workspaceDir = workspaceFolder.uri.fsPath;
const customBundleGemfile: string = vscode.workspace
.getConfiguration("rubyLsp")
.get("bundleGemfile")!;
Expand All @@ -191,31 +190,8 @@ export class RubyLsp {
// If no lockfile exists and we're activating lazily (if the user opened a Ruby file inside a workspace we hadn't
// activated before), then we start the language server, but we warn the user that they may be missing multi-root
// workspace configuration
if (
customBundleGemfile.length === 0 &&
!lockfileExists &&
!this.context.globalState.get("rubyLsp.disableMultirootLockfileWarning")
) {
const answer = await vscode.window.showWarningMessage(
`Activating the Ruby LSP in ${workspaceDir}, but no lockfile was found. Are you using a monorepo setup?`,
"See the multi-root workspace docs",
"Don't show again",
);

if (answer === "See the multi-root workspace docs") {
await vscode.env.openExternal(
vscode.Uri.parse(
"https://github.com/Shopify/ruby-lsp/blob/main/vscode/README.md?tab=readme-ov-file#multi-root-workspaces",
),
);
}

if (answer === "Don't show again") {
await this.context.globalState.update(
"rubyLsp.disableMultirootLockfileWarning",
true,
);
}
if (customBundleGemfile.length === 0 && !lockfileExists) {
await this.showStandaloneWarning(workspaceFolder.uri.fsPath);
}

const workspace = new Workspace(
Expand Down Expand Up @@ -797,4 +773,44 @@ export class RubyLsp {

return false;
}

private async showStandaloneWarning(workspaceDir: string) {
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: "No bundle found. Launching in standalone mode in 5 seconds",
cancellable: true,
},
async (progress, token) => {
progress.report({
message:
"If working in a monorepo, cancel to see configuration instructions",
});

await new Promise<void>((resolve) => {
token.onCancellationRequested(() => {
resolve();
});

setTimeout(resolve, 5000);
});

if (token.isCancellationRequested) {
const answer = await vscode.window.showWarningMessage(
`Could not find a lockfile in ${workspaceDir}. Are you using a monorepo setup?`,
"See the multi-root workspace docs",
"Launch anyway",
);

if (answer === "See the multi-root workspace docs") {
const uri = vscode.Uri.parse(
"https://github.com/Shopify/ruby-lsp/blob/main/vscode/README.md?tab=readme-ov-file#multi-root-workspaces",
);

await vscode.env.openExternal(uri);
}
}
},
);
}
}
Loading