wysiib / linter-languagetool

Integration of Languagetool into the Atom text editor.
MIT License
18 stars 5 forks source link

linter-languagetool not picking up config file #34

Closed dmohns closed 4 years ago

dmohns commented 5 years ago

The problem

I am running linter-languagetool with a locally installed languagetool server. I am trying to pass a config file to languagetool server using the settings interface of linter-languagetool. However, linter-languagetool does not seem to respect the config file.

Actual behavior

For testing purposes I use the following .languagetool.cfg:

maxTextLength=1

However, languagetool server started by linter-languagetool will not consider this config file. For example, if I send a POST

➜ http POST http://localhost:8081/v2/check text=="I can't remember how to go their." language==en-US
HTTP/1.1 200 OK
Content-length: 436
Content-type: application/json
Date: Mon, 06 May 2019 13:05:53 GMT

{
    "language": {
        "code": "en-US",
        "detectedLanguage": {
            "code": "en-US",
            "confidence": 0.99999094,
            "name": "English (US)"
        },
        "name": "English (US)"
    },
    "matches": [],
    "software": {
        "apiVersion": 1,
        "buildDate": "2019-03-26 11:37",
        "name": "LanguageTool",
        "premium": false,
        "premiumHint": "You might be missing errors only the Premium version can find. Contact us at support<at>languagetoolplus.com.",
        "status": "",
        "version": "4.5"
    },
    "warnings": {
        "incompleteResults": false
    }
}

Expected behavior

Now, to remove the possibility of problems with the config file itself, I check top for what is actually run and run the server myself.

➜ /usr/bin/java -cp /usr/local/Cellar/languagetool/4.5/libexec/languagetool-server.jar org.languagetool.server.HTTPServer --port 8082 --config /Users/daniel/.languagetool.cfg

Resulting in the expected behavior

➜ http POST http://localhost:8082/v2/check text=="I can't remember how to go their." language==en-US
HTTP/1.1 413 Request Entity Too Large
Content-length: 102
Date: Mon, 06 May 2019 13:21:39 GMT

Error: Your text exceeds the limit of 1 characters (it's 33 characters). Please submit a shorter text.

Environment

OS: macOS 10.14.4 Atom: 1.36.1 linter-languagetool: 0.9.0 languagetool 4.5 (installed via brew)

Further comments

I am not very familiar with Atom plugins, but did some further testing/exploration by modifying linter-languagetool's sources files directly.
It looks like the problem is originating from here

https://github.com/wysiib/linter-languagetool/blob/caea6b839e9110efc4f6dabe603b9fa83a590a5c/lib/ltserver-helper.coffee#L131

and here

https://github.com/wysiib/linter-languagetool/blob/caea6b839e9110efc4f6dabe603b9fa83a590a5c/lib/ltserver-helper.coffee#L152

If I modify it in a way that --config is passed hardcodedly via jvmoptions.concat the languagetool server correctly picks up the config file.