vim-LanguageTool
vim-LanguageTool copied to clipboard
Doesn't work with the latest LanguageTool version - 6.0
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
:+1: it seems they abandoned the XML output (it was marked as deprecated) in favor of the sole JSON.
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:
- https://groups.google.com/g/vim_dev/c/AVpp8DT2_Vc/m/NZ9h3F8gBQAJ
- https://github.com/languagetool-org/languagetool/issues/7462
- https://github.com/languagetool-org/languagetool/issues/991
- workaround at: https://github.com/languagetool-org/languagetool/issues/991#issuecomment-521026834
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.
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
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?
@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 ?
Hi, I thought I should post my steps here to get LanguageTool 5.9 working on Mac:
- install java sdk with brew:
$ brew install openjdk@11
- get LanguageTool 5.9 from MacPorts, manually download the zip, unzip it somewhere, https://cjj.kr.distfiles.macports.org/LanguageTool/
let g:languagetool_cmd='/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home/bin/java -jar $UNZIP_LOCATION/LanguageTool-5.9/languagetool-commandline.jar'
- maybe also do this:
export JAVA_HOME=/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home
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.
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.
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.
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
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.
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)
(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