dpelle/vim-LanguageTool

Error detected while processing function <SNR>54_LanguageToolCheck

sadid opened this issue · 1 comments

sadid commented

I've installed languagetool system-wide through my pacman manager. The languagetool-commandline.jar is located in /usr/share/java/languagetool/languagetool-commandlne.jar and I've set (in .vimrc):

let g:languagetool_jar='/usr/share/java/languagetool/languagetool-commandline.jar'

But when I issue the :LanguageToolCheck I get this error:

Error detected while processing function <SNR>54_LanguageToolCheck:
line   40:
Command [java -jar /usr/share/java/languagetool/languagetool-commandline.jar -c utf-8 -d WHITESPACE_RULE,EN_QUOTES -l en --api /tmp/vqOXQNe/10 2> /tmp/vqOXQNe/
11] failed with error: 1
line   43:
['Error: A JNI error has occurred, please check your installation and try again', 'Exception in thread "main" java.lang.NoClassDefFoundError: org/languagetool/
rules/Rule', '^Iat java.lang.Class.getDeclaredMethods0(Native Method)', '^Iat java.lang.Class.privateGetDeclaredMethods(Class.java:2701)', '^Iat java.lang.Clas
s.privateGetMethodRecursive(Class.java:3048)', '^Iat java.lang.Class.getMethod0(Class.java:3018)', '^Iat java.lang.Class.getMethod(Class.java:1784)', '^Iat sun
.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)', '^Iat sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)', 'Caused by:
 java.lang.ClassNotFoundException: org.languagetool.rules.Rule', '^Iat java.net.URLClassLoader.findClass(URLClassLoader.java:381)', '^Iat java.lang.ClassLoader
.loadClass(ClassLoader.java:424)', '^Iat sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)', '^Iat java.lang.ClassLoader.loadClass(ClassLoader.java
:357)', '^I... 7 more']

OS: Archlinux latest
Vim: 8.0.1176-1
languagetool: 3.8.1
vim-languagetool: lastest

I know it's pretty late to answer this. This error also occurred on my part. I'm using archlinux as well.

I found a workaround which implies that you have to change some things in the LanguageTool.vim script.

The script uses the .jar file, which, if I try to use it in any shell, it will also throw these errors. The languagetool binary however works fine. To use it I changed the l:languagetool_cmd as followed:

let l:languagetool_cmd = 'languagetool'
\ . ' -c ' . s:languagetool_encoding
\ . (empty(s:languagetool_disable_rules) ? '' : ' -d '.s:languagetool_disable_rules)
\ . (empty(s:languagetool_enable_rules) ? '' : ' -e '.s:languagetool_enable_rules)
\ . (empty(s:languagetool_disable_categories) ? '' : ' --disablecategories '.s:languagetool_disable_categories)
\ . (empty(s:languagetool_enable_categories) ? '' : ' --enablecategories '.s:languagetool_enable_categories)
\ . ' -l ' . s:languagetool_lang
\ . ' --api ' . l:tmpfilename
\ . ' 2> ' . l:tmperror

Now it is directly calling the binary without using the g:languagetool_jar variable. After this, it'll work properly.

It would be nice to have an option to change this without having to edit the script. In addition, it is only possible to check grammar for only one language at the same time. To change this, you must change the variable g:languagetool_lang, which can be tedious, when you are working between files with multiple languages.

It seems like this plugin is great but not fully matured. I would rather try out grammarous to see, if they accomplish this.