diff --git a/package.json b/package.json index c5f5aedd..8715a17a 100644 --- a/package.json +++ b/package.json @@ -485,6 +485,13 @@ "plaintext" ], "markdownDescription": "A list of [Language IDs](https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers) to treat as plain text." + }, + "languageToolLinter.disabledLanguageIds": { + "type": "array", + "items": { + "type": "string" + }, + "markdownDescription": "A list of [Language IDs](https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers) not to lint." } } } diff --git a/src/ConfigurationManager.ts b/src/ConfigurationManager.ts index d034c3d5..5c010fef 100644 --- a/src/ConfigurationManager.ts +++ b/src/ConfigurationManager.ts @@ -98,12 +98,15 @@ export class ConfigurationManager implements Disposable { ); } } - // List of plaintext ids changed - need to reload - if (event.affectsConfiguration("languageToolLinter.plainText")) { + // List of plaintext ids or disabled language ids changed - need to reload + if ( + event.affectsConfiguration("languageToolLinter.plainText") || + event.affectsConfiguration("languageToolLinter.disabledLanguageIds") + ) { const action = "Reload"; window .showInformationMessage( - "The settings for linting plaintext documents have changed. \ + "The settings for linting documents have changed. \ Please reload the window for the configuration to take effect.", action, ) @@ -163,7 +166,12 @@ export class ConfigurationManager implements Disposable { public getDocumentSelectors(): DocumentSelector[] { const selectors: DocumentSelector[] = []; - const languageIds = Constants.SUPPORTED_LANGUAGE_IDS; + const supportedLanguageIds = Constants.SUPPORTED_LANGUAGE_IDS; + const disabledLanguageIds: string[] = + this.config.get(Constants.CONFIGURATION_DISABLED_IDS) || []; + const languageIds = supportedLanguageIds.filter( + (languageId) => !disabledLanguageIds.includes(languageId), + ); if (this.isPlainTextEnabled()) { const plaintextLanguageIds: string[] = diff --git a/src/Constants.ts b/src/Constants.ts index e33a5b34..323aa9ad 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -50,6 +50,7 @@ export const CONFIGURATION_DISABLED_CATEGORIES = "languageTool.disabledCategories"; export const CONFIGURATION_PLAIN_TEXT_ENABLED = "plainText.enabled"; export const CONFIGURATION_PLAIN_TEXT_IDS = "plainText.languageIds"; +export const CONFIGURATION_DISABLED_IDS = "disabledLanguageIds"; export const CONFIGURATION_LANGUAGE = "language"; // LanguageTool Services