Skip to content

Commit

Permalink
feat: add languagetool.org premium API support (using form data for t…
Browse files Browse the repository at this point in the history
…he credentials) (#561)

Co-authored-by: Johan Girod <dev@johangirod.com>
Co-authored-by: David L. Day <1132144+davidlday@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 2, 2023
1 parent e5118f6 commit 62bd2e5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@
"default": "http://localhost:8081",
"description": "URL of your LanguageTool server. Defaults to localhost on port 8081."
},
"languageToolLinter.external.username": {
"type": "string",
"default": "",
"description": "Set to get Premium API access if you use the languagetool.org api instance: your username/email as used to log in at languagetool.org."
},
"languageToolLinter.external.apiKey": {
"type": "string",
"default": "",
"description": "Set to get Premium API access if you use the languagetool.org api instance: your API key."
},
"languageToolLinter.managed.classPath": {
"type": "string",
"default": "",
Expand Down
11 changes: 11 additions & 0 deletions src/ConfigurationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import execa from "execa";
import * as glob from "glob";
import * as path from "path";
import * as portfinder from "portfinder";
import { URL } from "url";
import {
commands,
ConfigurationChangeEvent,
Expand Down Expand Up @@ -391,6 +392,16 @@ export class ConfigurationManager implements Disposable {
Constants.EXTENSION_OUTPUT_CHANNEL.appendLine(ltKey + ": " + value);
}
});
// Only add user name and API key to options if set and we are using the
// external API
if (this.getServiceType() === Constants.SERVICE_TYPE_EXTERNAL) {
const username = this.get("external.username");
const apiKey = this.get("external.apiKey");
if (username && apiKey) {
parameters.set("username", username);
parameters.set("apiKey", apiKey);
}
}
// Make sure disabled rules and disabled categories do not contain spaces
const CONFIG_DISABLED_RULES = "languageTool.disabledRules";
const CONFIG_DISABLED_CATEGORIES = "languageTool.disabledCategories";
Expand Down

0 comments on commit 62bd2e5

Please sign in to comment.