Skip to content

Commit

Permalink
Allow turning off ERB support through setting (#2311)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock authored Jul 18, 2024
1 parent d3a463f commit b92c560
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
},
Expand Down
11 changes: 10 additions & 1 deletion vscode/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
ErrorAction,
CloseAction,
State,
DocumentFilter,
} from "vscode-languageclient/node";

import {
Expand Down Expand Up @@ -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}/**/*` };
},
Expand Down Expand Up @@ -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<boolean>("erbSupport")) {
documentSelector = documentSelector.filter((selector) => {
return (selector as DocumentFilter).language !== "erb";
});
}

return {
documentSelector,
workspaceFolder,
Expand Down

0 comments on commit b92c560

Please sign in to comment.