Skip to content

Commit

Permalink
Premium LanguageTool Account Setup (#20)
Browse files Browse the repository at this point in the history
* Add LanguageTool Premium API Functionality

* Update README for Premium Account setup

---------

Co-authored-by: Pass Automated Testing Suite <[email protected]>
  • Loading branch information
tpeacock19 and Pass Automated Testing Suite authored Feb 29, 2024
1 parent ad62f7e commit 7da39eb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 11 deletions.
49 changes: 39 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,28 @@

The instruction to use this plugin.

1. Download LanguageTool from https://languagetool.org/download/ and
extract on to your local machine (skip this step if using a remote
server).
2. Consider adding the following snippet to your configuration.
1. **For a Local Server:** Download LanguageTool from https://languagetool.org/download/ and
extract on to your local machine.
**For a Remote Server:** If you are using LanguageTool's API and have a premium
account you will need your username and an api key you can generate
here https://languagetool.org/editor/settings/access-tokens
2. Consider adding one of the following snippets to your configuration.

#### Local LanguageTool Server
```el
(use-package flymake-languagetool
:ensure t
:hook ((text-mode . flymake-languagetool-load)
(latex-mode . flymake-languagetool-load)
(org-mode . flymake-languagetool-load)
(markdown-mode . flymake-languagetool-load))
:init
;; Local Server Configuration
(setq flymake-languagetool-server-jar
"path/to/LanguageTool-X.X/languagetool-server.jar"))
```

#### Free LanguageTool Account
```el
(use-package flymake-languagetool
:ensure t
Expand All @@ -26,13 +43,25 @@ The instruction to use this plugin.
(org-mode . flymake-languagetool-load)
(markdown-mode . flymake-languagetool-load))
:init
;; Remote server config with LanguageTool's free API
;; (setq flymake-languagetool-url "https://api.languagetool.org")
;; (setq flymake-languagetool-server-port nil)
;; (setq flymake-languagetool-server-jar nil)
;; LanguageTools API Remote Server Configuration
(setq flymake-languagetool-server-jar nil)
(setq flymake-languagetool-url "https://api.languagetool.org"))
```

;; Local server config
(setq flymake-languagetool-server-jar "path/to/LanguageTool-X.X/languagetool-server.jar"))
#### Premium LanguageTool Account
```el
(use-package flymake-languagetool
:ensure t
:hook ((text-mode . flymake-languagetool-load)
(latex-mode . flymake-languagetool-load)
(org-mode . flymake-languagetool-load)
(markdown-mode . flymake-languagetool-load))
:init
;; If using Premium Version provide the following information
(setq flymake-languagetool-server-jar nil)
(setq flymake-languagetool-url "https://api.languagetoolplus.com")
(setq flymake-languagetool-api-username "myusername")
(setq flymake-languagetool-api-key "APIKEY"))
```

3. :tada: Done! Now open a text file and hit `M-x flymake-mode`!
Expand Down
16 changes: 15 additions & 1 deletion flymake-languagetool.el
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ It is an alist of (major-mode . faces-to-ignore)"
(string :tag "URL"))
:group 'flymake-languagetool)

(defcustom flymake-languagetool-api-username nil
"The username for accessing the Premium LanguageTool API"
:type 'string
:group 'flymake-languagetool)

(defcustom flymake-languagetool-api-key nil
"The API Key for accessing the Premium LanguageTool API"
:type 'string
:group 'flymake-languagetool)

(defcustom flymake-languagetool-server-jar nil
"The path of languagetool-server.jar.
Expand Down Expand Up @@ -321,7 +331,11 @@ STATUS provided from `url-retrieve'."
(unless (string-empty-p disabled-rules)
(list "disabledRules" disabled-rules))
(unless (string-empty-p disabled-cats)
(list "disabledCategories" disabled-cats))))
(list "disabledCategories" disabled-cats))
(when flymake-languagetool-api-username
(list "username" flymake-languagetool-api-username))
(when flymake-languagetool-api-key
(list "apiKey" flymake-languagetool-api-key))))
(url-request-data (url-build-query-string params nil t)))
(if (flymake-languagetool--reachable-p)
(setq flymake-languagetool--proc-buf
Expand Down

0 comments on commit 7da39eb

Please sign in to comment.