Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add feature to disable languages #806

Merged
merged 1 commit into from
Nov 23, 2024
Merged
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
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
}
Expand Down
16 changes: 12 additions & 4 deletions src/ConfigurationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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[] =
Expand Down
1 change: 1 addition & 0 deletions src/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading