From 2611f461f6b09b3056cb2fc1ee730d92a237f877 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Tue, 19 Dec 2023 09:16:52 -0500 Subject: [PATCH] Warn users if no lockfile is detected on the configured workspace (#945) --- src/rubyLsp.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/rubyLsp.ts b/src/rubyLsp.ts index 29ea0d541..462d67e66 100644 --- a/src/rubyLsp.ts +++ b/src/rubyLsp.ts @@ -116,9 +116,31 @@ export class RubyLsp { // `workspaceContains` activation events in package.json if ( !(await pathExists(path.join(workspaceDir, "Gemfile.lock"))) && - !(await pathExists(path.join(workspaceDir, "gems.locked"))) + !(await pathExists(path.join(workspaceDir, "gems.locked"))) && + !this.context.globalState.get("rubyLsp.disableMultirootLockfileWarning") ) { - return; + const answer = await vscode.window.showWarningMessage( + `Tried to activate the Ruby LSP in ${workspaceDir}, but no lockfile was found. Are you using a monorepo setup?`, + "No - launch without bundle", + "Yes - see multi-root workspace docs", + "Don't show again", + ); + + if (answer === "Yes - see multi-root workspace docs") { + vscode.env.openExternal( + vscode.Uri.parse( + "https://github.com/Shopify/vscode-ruby-lsp?tab=readme-ov-file#multi-root-workspaces", + ), + ); + return; + } + + if (answer === "Don't show again") { + this.context.globalState.update( + "rubyLsp.disableMultirootLockfileWarning", + true, + ); + } } const workspace = new Workspace(