|
| 1 | += Tools for writers |
| 2 | + |
| 3 | +== LanguageTool |
| 4 | + |
| 5 | +Grammar, style, and spell checking with https://marketplace.visualstudio.com/items?itemName=davidlday.languagetool-linter[LanguageTool Linter]. |
| 6 | + |
| 7 | +I switched from Grammarly to LanguageTool to more easily control my settings. I can now |
| 8 | +add custom spelling entries to my dictionary from VS Code easily. I am running the server |
| 9 | +on my laptop using Docker. |
| 10 | + |
| 11 | +I find the https://dev.languagetool.org/finding-errors-using-n-gram-data.html[ngram support] to be helpful |
| 12 | + |
| 13 | +I run LanguageTool in Docker. Erick van Leeuwen provides information for running https://github.com/Erikvl87/docker-languagetool[LanguageTool with Docker Compose]. |
| 14 | + |
| 15 | +The VS Code extension to use is [LanguageTool](https://marketplace.visualstudio.com/items?itemName=davidlday.languagetool-linter) |
| 16 | + |
| 17 | +Here are the config entries for VS Code: |
| 18 | + |
| 19 | +```json |
| 20 | + "editor.formatOnType": true, |
| 21 | + "languageToolLinter.languageTool.language": "en-US", |
| 22 | + "languageToolLinter.languageTool.motherTongue": "en-US", |
| 23 | + "languageToolLinter.lintOnChange": true, |
| 24 | + "languageToolLinter.lintOnOpen": true, |
| 25 | +``` |
| 26 | + |
| 27 | +At the end of this README is the `docker-compose.yml` that I use, it is based on Eric van Leeuwen's (linked above). I added some configuration for my preferences. These are described below. |
| 28 | + |
| 29 | +The compose file passes the environment to `start.sh` (maintained |
| 30 | +by https://github.com/Erikvl87/docker-languagetool[erikvl87]), and any env vars that begin with `langtool_` are |
| 31 | +considered to be entries for a configuration file that will be |
| 32 | +passed to the `langtool` server. |
| 33 | + |
| 34 | +If you see in the LanguageTool docs "Add `disabledRuleIds= a comma separated list |
| 35 | +of Rule IDs to ignore`, then the entry in the docker compose file |
| 36 | +to disable the WHITESPACE_RULE and the EN_UNPAIRED_BRACKETS rule would be: |
| 37 | + |
| 38 | +.Disable Whitespace and unpaired bracket rules |
| 39 | +[source, yaml] |
| 40 | +---- |
| 41 | + - langtool_disabledRuleIds=WHITESPACE_RULE,EN_UNPAIRED_BRACKETS |
| 42 | +---- |
| 43 | + |
| 44 | +I disable the WHITESPACE_RULE as it marks every line of a Markdown |
| 45 | +table as a problem if you use more than one space to pad entries |
| 46 | +(I like to line the `|` symbols up on each row with the longest |
| 47 | +entry in a column). |
| 48 | + |
| 49 | +I disable the EN_UNPAIRED_BRACKETS as it complains unpaired square brackets used for Asciidoc URLs (spaces in the link text trigger the rule). |
| 50 | + |
| 51 | +The rule IDs can be found in VS Code in the problems view. |
| 52 | + |
| 53 | +Similarly, the env line to specify the location of the ngrams is: |
| 54 | + |
| 55 | +.Enable ngrams support |
| 56 | +[source, yaml] |
| 57 | +---- |
| 58 | + - langtool_languageModel=/ngrams/ |
| 59 | +---- |
| 60 | + |
| 61 | +This assumes that you mount the ngrams from your host machine to |
| 62 | +`/ngrams` in the container. I do so like this: |
| 63 | + |
| 64 | +.Mount the ngrams volume |
| 65 | +[source, yaml] |
| 66 | +---- |
| 67 | + volumes: |
| 68 | + - /Users/droscign/ngrams:/ngrams |
| 69 | +---- |
| 70 | + |
| 71 | +.docker-compose.yaml |
| 72 | +[source, yaml] |
| 73 | +---- |
| 74 | +services: |
| 75 | + languagetool: |
| 76 | + image: erikvl87/languagetool |
| 77 | + container_name: languagetool |
| 78 | + ports: |
| 79 | + - 8081:8010 # Using default port from the image |
| 80 | + environment: |
| 81 | + - langtool_languageModel=/ngrams/ |
| 82 | + - langtool_disabledRuleIds=WHITESPACE_RULE,EN_UNPAIRED_BRACKETS |
| 83 | + - Java_Xms=512m # OPTIONAL: Setting a minimal Java heap size of 512 mib |
| 84 | + - Java_Xmx=1g # OPTIONAL: Setting a maximum Java heap size of 1 Gib |
| 85 | + volumes: |
| 86 | + - /Users/droscign/ngrams:/ngrams |
| 87 | +---- |
0 commit comments