diff --git a/package.json b/package.json index f60199d..e1c0ee1 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,8 @@ ], "activationEvents": [ "onLanguage:ruby", - "workspaceContains:Gemfile.lock" + "workspaceContains:Gemfile.lock", + "workspaceContains:**/.standard.yml" ], "main": "./out/extension", "contributes": { @@ -102,6 +103,15 @@ "type": "string", "default": "", "markdownDescription": "Absolute path to standardrb executable. Overrides default search order and, if missing, will not run Standard via Bundler or a `standardrb` executable on your PATH.\n\nSupports variables `${userHome}`, `${pathSeparator}`, and `${cwd}`" + }, + "standardRuby.additionalLanguages": { + "order": 4, + "type": "array", + "items": { + "type": "string" + }, + "default": [], + "markdownDescription": "Additional [VS Code language identifiers](https://code.visualstudio.com/docs/languages/identifiers) to send to the Standard Ruby language server, in addition to `ruby` and `Gemfile`.\n\nUse this to lint non-Ruby files that a custom RuboCop cop handles via `on_other_file` — for example `[\"yaml\"]` for a plugin that validates `data/**/*.yml`, or `[\"erb\"]` for an ERB linter.\n\n**Important:** Standard's built-in cops must be excluded for these files in your project config (e.g. `Lint`/`Layout`/… `Exclude: \"**/*.yml\"`), otherwise every file of that type will be parsed as Ruby and report `Lint/Syntax` errors." } } } diff --git a/src/extension.ts b/src/extension.ts index ebb71b5..2014dfa 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -85,8 +85,12 @@ function getConfig (key: string): T | undefined { return workspace.getConfiguration('standardRuby').get(key) } +function additionalLanguages (): string[] { + return getConfig('additionalLanguages') ?? [] +} + function supportedLanguage (languageId: string): boolean { - return languageId === 'ruby' || languageId === 'gemfile' + return languageId === 'ruby' || languageId === 'gemfile' || additionalLanguages().includes(languageId) } function registerCommands (): Disposable[] { @@ -267,6 +271,7 @@ function buildLanguageClientOptions (): LanguageClientOptions { return { documentSelector: [ { scheme: 'file', language: 'ruby' }, + ...additionalLanguages().map((language) => ({ scheme: 'file', language })), { scheme: 'file', pattern: '**/Gemfile' } ], diagnosticCollectionName: 'standardRuby',