emacs-languagetool / flymake-languagetool

Flymake support for LanguageTool
GNU General Public License v3.0
33 stars 11 forks source link

Installation guide: show example how to setup with username/apikey #17

Closed sdalu closed 8 months ago

sdalu commented 9 months ago

From the installation section, it is not obvious to find how to configure flymake-languagetool for a premium account, or even if it is possible. Please provide an example.

tpeacock19 commented 9 months ago

Thanks, I do not use a premium account, so I will need your help ensuring it works. Can you try using the 'feat/premium-api' branch, and follow the updated README instructions?

The easiest way to determine if you are using the premium API is to try with a buffer that has greater than 20,000 characters. Here is a lorem ipsum you can try. If you receive any errors please let me know.

sdalu commented 9 months ago

In the downloaded melpa package, I removed the flymake-languagetool.elc and replace the flymake-languagetool.el with the one from feat/premium-api branch.

Actual configuration is

(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
  ;; Remote server config with LanguageTool's free API
  (setq flymake-languagetool-server-jar nil)
  (setq flymake-languagetool-url "https://api.languagetool.org")
  (setq flymake-languagetool-api-username "xxx")
  (setq flymake-languagetool-api-key "xxx")

I get the following messages when running flymake-mode

error in process filter: json-read-from-string: JSON readtable error: 69
error in process filter: JSON readtable error: 69
tpeacock19 commented 9 months ago

Okay great. Can you share with me the contents of the buffer named ' http api.languagetool.org:443'. Please note that there is a space before the 'http'. It is a hidden buffer that should contain the error response from the API.

sdalu commented 9 months ago

Looks like I wasn't using the correct server.

HTTP/1.1 400 Bad Request
server: nginx/1.24.0
date: Thu, 01 Feb 2024 14:20:19 GMT
content-length: 73
access-control-allow-origin: *
x-backend-server: api64
x-request-id: E0D9:2A0104F8C0101EF10000000000000001:01BB:65BBA8A3:25BC58C:58F4
strict-transport-security: max-age=63072000

Error: Credentials provided, but server isn't configured to support this.

Seems fixed by using: https://api.languagetoolplus.com instead

tpeacock19 commented 9 months ago

Ah that is odd. It seems there are different urls referenced on their site hereand here. I'll make a note of that in the README and merge the code.

Thanks for your help!