rhysd / vim-grammarous

A powerful grammar checker for Vim using LanguageTool.
1.1k stars 41 forks source link

Breaking changes in LanguageTool #110

Open filmmakerto opened 1 year ago

filmmakerto commented 1 year ago

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.

ghost commented 1 year ago

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.

rodolfoap commented 1 year ago

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.

rhysd commented 1 year ago

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

agherzan commented 1 year ago

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.

zampierilucas commented 1 year ago

Workaround for neovim lua config:

vim.g.grammarous_jar_url = 'https://www.languagetool.org/download/LanguageTool-5.9.zip'
borisdev commented 1 year ago

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.

stelgenhof commented 1 year ago

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.

ThiagoMowszet commented 1 year ago

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

ivanalejandro0 commented 11 months ago

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'
kaimast commented 2 months ago

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.