vim-grammarous icon indicating copy to clipboard operation
vim-grammarous copied to clipboard

Breaking changes in LanguageTool

Open filmmakerto opened this issue 2 years ago • 11 comments

LanguageTool 6.0 was released on 2022-12-29. It no longer supports the "--api" command line option, which was already deprecated in 5.9. If vim-grammarous was installed after the 6.0 release, running :GrammarousCheck leads to the following error:

vim-grammarous: Grammar check failed: Unknown parameter: --api

I thought I could temporarily fix this by manually downloading v5.9 from https://languagetool.org/download/ and replacing the 6.0 files (which, in my case, because I installed the plugin via packer on Arch, are in ~/.local/share/nvim/site/pack/packer/start/vim-grammarous/misc/LanguageTool-6.0) with the 5.9 files, but this does not work: After doing this, the plugin runs without errors again, but it no longer detects any grammatical errors.

As I found out by checking on another computer, this is also true if the plugin was installed before the 6.0 release and no files have been manually replaced. So if I'm not missing something major here, it seems like there was a breaking change in the LanguageTool API that completely breaks this plugin, no matter what version of the LanguageTool cli is installed locally.

filmmakerto avatar Jan 05 '23 10:01 filmmakerto

I got the same error message both on dpelle/vim-LanguageTool and on this plugin.

For me, however, extracting LanguageTool-5.9.zip into $HOME/.local/share/nvim/plugged/vim-grammarous/misc made it work, but for my language, when I make a mistake, it shows what was the error, what is the context of it, but fails to underscore it correctly (I have exactly the same issue as this guy, though Russian is not my native language).

Anyway, are you sure that you used correct option for the --lang parameter? If it still doesn't work then maybe you should give vim-LanguageTool a try with the LanguageTool-5.9.

Note that I installed both this and the second plugin via vim-plug.

ghost avatar Jan 05 '23 16:01 ghost

Simple and temporary patch: I've created a fork and rolled it back to 5.9 (https://github.com/rhysd/vim-grammarous/compare/master...rodolfoap:vim-grammarous:master) so, I use:

use 'rodolfoap/vim-grammarous'

Seems working for now. Sorry, no time to address the real issue.

rodolfoap avatar Jan 08 '23 07:01 rodolfoap

From the changelog:

The --api parameter for the command-line version has been removed. It had long been deprecated and replaced by --json.

We need to replace --api with --json

rhysd avatar Jan 08 '23 11:01 rhysd

You don't need a fork. Just set the parameter:

let g:grammarous#jar_url = 'https://www.languagetool.org/download/LanguageTool-5.9.zip'

And reinstall the plugin.

agherzan avatar Jan 26 '23 11:01 agherzan

Workaround for neovim lua config:

vim.g.grammarous_jar_url = 'https://www.languagetool.org/download/LanguageTool-5.9.zip'

zampierilucas avatar Mar 13 '23 12:03 zampierilucas

Four steps that fixed the bug on my mac

Context: As others have pointed out, Grammarous depends on the java Language Tool, and when Language Tool 6.0 changed their API, deprecating the use of --api, it broke Grammarous for its new users. Grammarous's developers have not gotten around to change this part of the code.

Step 1: Manually download https://www.languagetool.org/download/LanguageTool-5.9.zip.

Step 2: Move LanguageTool to your Grammarous plugin's misc directory.

cp -rf ~/Downloads/LanguageTool-5.9 .local/share/nvim/plugged/vim-grammarous/misc/

Remember, your misc dir and mine might be in different locations.

Step 3: Remove the recent Language Tool, which breaks, and use the older one now.

rm -rf .local/share/nvim/plugged/vim-grammarous/misc/LanguageTool-6.0

Step 4: Clean up your init.vim or lua.init. Mine required nothing to get Grammarous working with the defaults.

borisdev avatar Mar 14 '23 17:03 borisdev

Can confirm @borisdev steps solved the issue for me (Linux). Although of course this just a band-aid and hopefully the maintainers will adjust the code to make it work with Language Tool 6.

stelgenhof avatar Apr 18 '23 12:04 stelgenhof

Thanks @borisdev, works for me! :1st_place_medal:

ThiagoMowszet avatar Jul 27 '23 16:07 ThiagoMowszet

Workaround for neovim lua config:

vim.g.grammarous_jar_url = 'https://www.languagetool.org/download/LanguageTool-5.9.zip'

You need to keep the "#" part for the plugin to find it, in lua you have to set it like so:

vim.g["grammarous#jar_url"] = 'https://www.languagetool.org/download/LanguageTool-5.9.zip'

ivanalejandro0 avatar Oct 04 '23 03:10 ivanalejandro0

I had a different error message "Grammar check failed with status 1" but the workaround fixed it for me too.

Is vim-grammarous not mainted anymore? The last commit is from four years ago.

kaimast avatar Jul 11 '24 00:07 kaimast