Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
],
"activationEvents": [
"onLanguage:ruby",
"workspaceContains:Gemfile.lock"
"workspaceContains:Gemfile.lock",
"workspaceContains:**/.standard.yml"
],
"main": "./out/extension",
"contributes": {
Expand Down Expand Up @@ -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."
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ function getConfig<T> (key: string): T | undefined {
return workspace.getConfiguration('standardRuby').get<T>(key)
}

function additionalLanguages (): string[] {
return getConfig<string[]>('additionalLanguages') ?? []
}

function supportedLanguage (languageId: string): boolean {
return languageId === 'ruby' || languageId === 'gemfile'
return languageId === 'ruby' || languageId === 'gemfile' || additionalLanguages().includes(languageId)
}

function registerCommands (): Disposable[] {
Expand Down Expand Up @@ -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',
Expand Down