From aaf2c0f68c6ec4c1a3b86486fa6dd229b5b0b2c5 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Fri, 9 Feb 2024 17:01:15 -0500 Subject: [PATCH] Add gem paths to document selector patterns --- src/client.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/client.ts b/src/client.ts index 3a815b02..da3aeba5 100644 --- a/src/client.ts +++ b/src/client.ts @@ -91,6 +91,7 @@ function collectClientOptions( configuration: vscode.WorkspaceConfiguration, workspaceFolder: vscode.WorkspaceFolder, outputChannel: WorkspaceChannel, + ruby: Ruby, ): LanguageClientOptions { const pullOn: "change" | "save" | "both" = configuration.get("pullDiagnosticsOn")!; @@ -102,10 +103,27 @@ function collectClientOptions( const features: EnabledFeatures = configuration.get("enabledFeatures")!; const enabledFeatures = Object.keys(features).filter((key) => features[key]); - const pattern = `${path.join(workspaceFolder.uri.fsPath, "**", "*")}`; + + const documentSelector = [ + { + language: "ruby", + pattern: path.join(workspaceFolder.uri.fsPath, "**", "*"), + }, + ]; + + if (ruby.env.GEM_PATH) { + const parts = ruby.env.GEM_PATH.split(path.delimiter); + + parts.forEach((gemPath) => { + documentSelector.push({ + language: "ruby", + pattern: path.join(gemPath, "**", "*"), + }); + }); + } return { - documentSelector: [{ language: "ruby", pattern }], + documentSelector, workspaceFolder, diagnosticCollectionName: LSP_NAME, outputChannel, @@ -149,6 +167,7 @@ export default class Client extends LanguageClient implements ClientInterface { vscode.workspace.getConfiguration("rubyLsp"), workspaceFolder, outputChannel, + ruby, ), );