dpelle / vim-LanguageTool

A vim plugin for the LanguageTool grammar checker
280 stars 28 forks source link

Doesn't work with the latest LanguageTool version - 6.0 #33

Open ghost opened 1 year ago

ghost commented 1 year ago

When I type :LanguageToolCheck, and it uses the latest version of LanguageTool - 6.0, it outputs an error message. It's quite long, so I will just send it here as a text file.

Also, I found this in the LanguageTool's CHANGES.md:

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

Which is probably the reason why it no longer works, as this error starts with:

'Unknown parameter: --api'

It works fine with version 5.9

tarikgraba commented 1 year ago

:+1: it seems they abandoned the XML output (it was marked as deprecated) in favor of the sole JSON.

dpelle commented 1 year ago

Yes, I am aware of the reason why the Vim plugin does not work latest LanguageTool. I need to update the plugin to use the JSON format, which in principle should make the plugin simpler, since Vim understands JSON nowadays. However, the JSON response from LanguageTool no longer includes the line/column of each error which is unfortunate. It instead gives the Unicode character offset from the beginning of the file. There is no good function in Vim to convert it in line/column, although there is an "ugly" workaround (not sure how slow it will be).

More info at:

And unfortunately, I do not have a lot of spare time these days for this, but I have not forgotten. I was hoping to fix it during my Christmas holidays, but I did not.

tobalr commented 1 year ago

Older versions of LanguageTool can be downloaded from their download page https://languagetool.org/download/ Version 5.9 seems to be the latest working version

revolutionnaire commented 1 year ago

Where is a good place to unzip the old version to? Homebrew doesn't provide older versions, and it installs it in the /opt/ folder. Is it better to place it there also?

Britaliope commented 1 year ago

@dpelle Any idea if you'll have time to look at this at some point ?

I don't have much time myself, but i'd like to help anyway, however i don't have that much experience with vimscript.

What was the fix you were hoping to work on last christmas : was it the workaround you linked above, or a patch in Languagetool to publish the needed information in the API ?

michaelfresco commented 1 year ago

Hi, I thought I should post my steps here to get LanguageTool 5.9 working on Mac:

michaelfresco commented 1 year ago

Where is a good place to unzip the old version to? Homebrew doesn't provide older versions, and it installs it in the /opt/ folder. Is it better to place it there also?

I think that it does not really matter, you could use perhaps ~/.langtool or ~/.local/langtool, or /opt/langtool. Just don't place it at the same location, as where Homebrew wants to put things, because you might break something.

Britaliope commented 9 months ago

For people looking for an alternative tool: I switched to TeXtidote, using https://github.com/PatrBal/vim-textidote which works correctly using latest versions of Languagetool. It also have the added benefits of parsing the latex syntax, so it don't trigger grammar errors on latex keywords or \usepackage names.

dpelle commented 9 months ago

I will try to have a look at fixing this (switching to the "new" JSON API instead of the new defunct XML API) in my Chrismas holidays. Unfortunately, the JSON API does not contain the same information as the previous XML API which complicates things.

I just glanced at https://github.com/PatrBal/vim-textidote/blob/master/autoload/textidote.vim and it appears to be using XML too so unless I'm missing something, it should also not work with the latest LanguageTool. It in fact mostly copied the parsing code from my plugin.

Britaliope commented 9 months ago

I just glanced at https://github.com/PatrBal/vim-textidote/blob/master/autoload/textidote.vim and it appears to be using XML too so unless I'm missing something, it should also not work with the latest LanguageTool. It in fact mostly copied the parsing code from my plugin.

vim-textidote integrate with textidote (https://github.com/sylvainhalle/textidote), which provide spell/grammar checking on LaTeX and Markdown documents using LanguageTool as a backend. However vim-textidote can also integrate directly with LanguageTool, buypassing textidote, and this can be used for other documents that are not LaTeX or Markdown. This integration is indeed heavily based on yours (as stated in the readme).

The LanguageTool integration is indeed not compatible with newer versions of languagetool. However, the textidote version relies on textidote, which is a java applet that directly uses the languagetool Jar so it doesn't have the xml vs json API problem

Toreno96 commented 8 months ago

If you're using Homebrew to install LanguageTool, you can also rely on this solution to install the older version and keep it from updating to the unsupported one. That way you don't need to bother with MacPorts, textidote, or install the LanguageTool manually, and the old configuration of vim-LanguageTool (e.g. let g:languagetool_cmd='languagetool') from before this issue started to happen should work.

michaelfresco commented 8 months ago

If you're using Homebrew to install LanguageTool, you can also rely on this solution to install the older version and keep it from updating to the unsupported one.

Thank you! The steps by Kache/Adrian from linked Stack Overflow page are really good. (I actually don't have a "core" folder, in /opt/homebrew/core, so I had to adjust it a little bit, but still this is really cool)

Toreno96 commented 8 months ago

(I actually don't have a "core" folder, in /opt/homebrew/core, so I had to adjust it a little bit, but still this is really cool)

@michaelfresco Yeah, it requires an additional step on the current version of Homebrew: https://stackoverflow.com/questions/39187812/how-to-install-older-versions-using-homebrew/46306176#comment137061519_46306176