diff --git a/vscode/package.json b/vscode/package.json index 8839aa0e0..20e6810de 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -418,6 +418,11 @@ } } } + }, + "rubyLsp.erbSupport": { + "description": "Enable ERB support. This can only work with server versions v0.17.5 or above", + "type": "boolean", + "default": true } } }, diff --git a/vscode/src/client.ts b/vscode/src/client.ts index 831b90d66..9f73a3058 100644 --- a/vscode/src/client.ts +++ b/vscode/src/client.ts @@ -21,6 +21,7 @@ import { ErrorAction, CloseAction, State, + DocumentFilter, } from "vscode-languageclient/node"; import { @@ -119,7 +120,7 @@ function collectClientOptions( const enabledFeatures = Object.keys(features).filter((key) => features[key]); const fsPath = workspaceFolder.uri.fsPath.replace(/\/$/, ""); - const documentSelector: DocumentSelector = SUPPORTED_LANGUAGE_IDS.map( + let documentSelector: DocumentSelector = SUPPORTED_LANGUAGE_IDS.map( (language) => { return { language, pattern: `${fsPath}/**/*` }; }, @@ -158,6 +159,14 @@ function collectClientOptions( }); } + // This is a temporary solution as an escape hatch for users who cannot upgrade the `ruby-lsp` gem to a version that + // supports ERB + if (!configuration.get("erbSupport")) { + documentSelector = documentSelector.filter((selector) => { + return (selector as DocumentFilter).language !== "erb"; + }); + } + return { documentSelector, workspaceFolder,