GVim 7.4, LanguageTool 2.5

I just installed LanguageTool on my Windows System.

By calling it from within Vim I get:

:LanguageToolCheck

Error detected while processing function 25_LanguageToolCheck:
line 34:
Command [java -jar d:\apps\LanguageTool-2.5\languagetool-commandline.jar
-c utf-8 -d WHITESPACE_RULE,EN_QUOTES -l de --api
C:\Users\me\AppData\Local\Temp\VIGC33A.tmp 2>
C:\Users\me\AppData\Local\Temp\VIHC33B.tmp] failed with error: 1
Press ENTER or type command to continue

Env:
Java JDK: java version “1.7.0_51”
GVim 7.4.142
LanguageTool 2.5
Vim Plugin for LanguageTool 1.28 from LanguageTool - Grammar checker for English, French, German (etc.) in Vim : vim online

_vimrc:
let g:languagetool_jar=‘d:\apps\LanguageTool-2.5\languagetool-commandline.jar’

Where is my mistake?
Thanks in advance
vbd

Hi Vbd

I’m the author of the Vim plugin. I’ve never tested it on Windows, I only use Linux. However, looking at the error message, it looks like the backslashes in…
let g:languagetool_jar=‘d:\apps\LanguageTool-2.5\languagetool-commandline.jar’
… have disappeared somewhere. Glancing at the source code of the plugin, I think I know what causes it.

It’s probably this line in plugin/LanguageTool.vim which causes the bug on Windows:
let l:languagetool_jar = expand(s:languagetool_jar)

Replacing it with…
let l:languagetool_jar = s:languagetool_jar
… will workaround it. You’d only lose the fact that you then cannot use environment variables such as let g:languagetool_jar=’$HOME/yadayadayada/languagetool-commandline.jar’ when setting g:languagetool_jar but that’s not very important.

Alternatively, using slashes / instead of backslashes \ in the path in g:languagetool_jar may also work on Windows (I have not tried yet). I will try to test on Windows this coming weekend so I can hopefully fix it and I will then post a new version. In the mean time, let me know if these workarounds work for you.

Dominique

Hi Dominique,

Thank you for your response and thank you for the Vim-Plugin!

I did the following:
Changed Line 167 in plugin\languagetool.vim
before: let l:languagetool_jar = expand(s:languagetool_jar)
after: let l:languagetool_jar = s:languagetool_jar

Didn’t work!

Also tried the following in _vimrc:
let g:languagetool_jar=‘d:/apps/LanguageTool-2.5/languagetool-commandline.jar’
let g:languagetool_jar=‘d:\apps\LanguageTool-2.5\languagetool-commandline.jar’

Tested it with original line 167 in languagetool.vim and the modified one.
Didn’t work.

Error detected while processing function 25_LanguageToolCheck:
line 34:
Command [java -jar d:\apps\LanguageTool-2.5\languagetool-commandline.jar
-c utf-8 -d WHITESPACE_RULE,EN_QUOTES -l de --api C:\Users\me\AppData\Lo
cal\Temp\VIA36E0.tmp 2> C:\Users\me\AppData\Local\Temp\VIB36E1.tmp] failed
with error: 1
Press ENTER or type command to continue

If I run the command of the error message in the command line window it seems to work.
With java -jar -verbose … also no error messages.

vbd

I’ve just tried the plugin for Vim (version 1.28 LanguageTool - Grammar checker for English, French, German (etc.) in Vim : vim online) on Windows Vista and it works fine for me out of the box, without making any change. The minimalistic $HOME/_vimrc file contained:

set enc=utf8
set fileencoding=utf8
set spelllang=fr
let g:languagetool_jar=‘C:\temp\LanguageTool-2.5\languagetool-commandline.jar’

This machine had an old GVim installed already (GVim-7.3.107). I’ll try a more recent version GVim-7.4.* later (be patient, it’s not my machine…) but if it works with GVim-7.3, it most likely will also work with GVim-7.4 too. I must admit that I don’t know why it does not work for you. This error was never reported to me earlier. Seeing that there are 4100 downloads of the LanguageTool plugin for Vim, I assume it works on Windows for other users too.

Which version of Windows are you using? Can you perhaps try on another machine?


I’ve also tested successfully the LanguageTool plugin (1.28) for Vim using Vim-7.4.213 Cream (for Vim) - Browse Files at SourceForge.net) for Windows (Vista). I used LanguageTool-2.5 (standalone version). The java version was:

java version “1.7.0_51”
Java™ SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot™ Client VM (build 24.51-b03, mixed mode)

Perhaps something inteferes in your configuration. Can you try with a minimalistic $HOME/_vimrc?

Hi Dominique,

thank you for your help. I tested following:

_vimrc:
set enc=utf8
set fileencoding=utf8
set spelllang=fr
let g:languagetool_jar=‘d:\apps\LanguageTool-2.5\languagetool-commandline.jar’

results in:
Error detected while processing function 14_LanguageToolCheck:
line 34:
Command [java -jar d:\apps\LanguageTool-2.5\languagetool-commandline.jar -c utf-8 -d WHITESPACE_RULE,EN_QUOTES -l fr --api C:\Users\me\AppData\Local\Temp\VIA3ACC.tmp 2> C:\Users\me\Appdata\Local\Temp\VIB3ACD.tmp]
failed with error: 1

Next step I made a backup copy of my plugins folder and removed all vim-plugins except languagetool.vim

results in:
Error detected while processing function 2_LanguageToolCheck:
line 34:
Command [java -jar d:\apps\LanguageTool-2.5\languagetool-commandline.jar -c utf-8 -d WHITESPACE_RULE,EN_QUOTES -l fr --api C:\Users\me\AppData\Local\Temp\VIA3ACC.tmp 2> C:\Users\me\Appdata\Local\Temp\VIB3ACD.tmp]
failed with error: 1

I tested also languagetool 2.4.1 with the same result. I think it must be
something with my setup. Will have to dig to find out - anyway thank you
very much for you assistance!

vbd

Calling LanguageTool from command line against a existing file works:
java -jar d:\apps\LanguageTool-2.5\languagetool-commandline.jar -c utf-8 -d WHITESPACE_RULE,EN_QUOTES -l de --api d:\work\index.md

java -jar d:\apps\LanguageTool-2.5\languagetool-commandline.jar -c utf-8 -d WHITESPACE_RULE,EN_QUOTES -l de --api C:\Users\me\AppData\Local\Temp\VIA3ACC.tmp …

If I lookup C:\Users\me\AppData\Local\Temp\ there is no input file VIA3ACC.tmp
Any idea why there is no temp input file created?

I can create files within C:\Users\me\AppData\Local\Temp\ so it shouldn’t be a permission issue.

If I lookup C:\Users\me\AppData\Local\Temp\ there is no
input file VIA3ACC.tmp
Any idea why there is no temp input file created?

The script is deleting the temporary when done with it.
That’s most certainly why you do not see it.
Line 248 in $HOME\vimfiles\plugin\LanguageTool.vim deletes the temporary file:

call delete(l:tmpfilename)

You could remove or comment out the line as an experiment,
to see what the temporary file contains. You can comment out
with a quote:

" call delete(l:tmpfilename)

The temporary file should contain the xml output of LanguageTool.

In Vim, once you get the error, you could also try typing the command…

:message

… it may display useful previous error messages.

I doubt the problem is with the temporary files.
In fact the error message that you see also comes from another temporary
file, so writing temporary files appears to work.

If the tmp file appears to be the problem (?) I could change the script to use
stdin rather than a temporary file. The reason I used a temporary file is
because LanguageTool used to report incorrect line number when using stdin.
Probably this old LanguageTool bug has been fixed by now. I will check that later.

Sorry for my delayed answer.

The line for deleting the tempfile is commented out.
I get the same error from within vim.

Running the java command in the command line:
java -jar d:\apps\LanguageTool-2.5\languagetool-commandline.jar -c utf-8 -d WHITESPACE_RULE,EN_QUOTES -l de --api C:\Users\me\AppData\Local\Temp\VIAF66A.tmp 2> C:\Users\me\AppData\Local\Temp\VIBF66B.tmp]

Results in:

<?xml version="1.0" encoding="UTF-8"?>

Executing :message after the error messages results in:

Messages maintainer: Bram Moolenaar Bram@vim.org
Error detected while processing function 25_LanguageToolCheck:
line 34:
Command [java -jar d:\apps\LanguageTool-2.5\languagetool-commandline.jar -c utf-8 -d WHITESPACE_RULE,EN_QUOTES -l de --api C:\Users\me\AppData\Local\Temp\VIA29B1.tmp 2> C:\Users\me\AppData\Local\Temp\VIB29B2.tmp] failed with error: 1

Hi,

I have tried and successfully installed LanguageTool onto my Vim. I am using a Windows 8.1 machine.

Here goes the GitHub Repo for recording how I made the shot.

All the best,

  • Linfeng

I am using latest Vim under Windows7
I added to my vimrc: let g:languagetool_jar=“E:/progs/LanguageTool-2.6/languagetool-commandline.jar”
Now, If I open previously saved text file (using right mouse button and “edit with vim”) and use “LangageToolCheck” command everything works fine, works as intended, or almost as intended.

But IF I just start vim and start typing in buffer and use “LangageToolCheck” I got error message:
Error detected processing function 24_LanguageToolCheck:
line 34:
Command [java -jar E:/progs/LanguageTool-2.6/languagetool-commandline.jar -c utf-8 - d WHITESPACE_RULE, EN_QUOTES -l pl --api C:/Users/Admin/Local/Temp/VIE85D0.tmp 2> c:/Users/Admin/AppData/Local/Temp/VIF85D1.tmp] failed with error: 2
Press ENTER or type command to continue

If I open vim and start typing, then save buffer (:w filename.txt) and use “LanguageToolCheck” command same happens - ERROR. But If I’ll save, exit vim, then open file with “edit with vim” it works… kind a annoying.

I checked enc and fenc, but can’t see anything what could cause problem here…
Any advice how to fix this?!

I think they may be some problem with this temp files - how can I modify plugin to save temp files to some defined location (like e:/temp for example) instead of $HOME (I don’t want to mess with global $HOME seting)?

I’m not able to reproduce the problem. I don’t have Windows on my machine but I just borrowed a Windows (Vista) computer and it worked fine, whether I used a new opened an existing file or whether I checked text in a new Vim window.

I don’t think that it’s a problem with the plugin. It seems that Vim is not able to spawn LanguageTool command line somehow from Vim. I have no idea why. Maybe it’s related to Windows UAC (User Access Control). I have not tried on any version of Windows newer than Windows Vista since I don’t have Windows. But many people have downloaded the LanguageTool plugin for Vim and I have not heard about that problem before (well 2 users in this thread, both Windows users) so it’s odd. Or maybe it’s related to your settings in _vimrc. In particular, did you perhaps change the default ‘shell’ variable from Vim?

Can you first try with a minimalistic _vimrc to ensure that there is no special setting of yours that may interfere? In a earlier message in this thread, I used this _vimrc and it worked for me on Windows Vista:

set enc=utf8
set fileencoding=utf8
set spelllang=fr
let g:languagetool_jar=‘C:\temp\LanguageTool-2.6\languagetool-commandline.jar’

Now if you think that there is some problem with TEMP files, you can change these two lines in plugin/LanguageTool.vim:

let l:tmpfilename = tempname()
let l:tmperror = tempname()

Just put (as an experiment) another file name there such as:

let l:tmpfilename = ‘C:/temp/tmp-lt.txt’
let l:tmperror = ‘C:/temp/tmp-lterr.txt’

I tried with a minimalistic _vimrc and got the same error as previously.

I replaced
let l:tmpfilename = tempname()
let l:tmperror = tempname()
with:
let l:tmpfilename = ‘E:/temp/tmp-lt.txt’
let l:tmperror = ‘E:/temp/tmp-lterr.txt’
An now I got the same error message - just related to specific temp files:

Error detected processing function 24_LanguageToolCheck:
line 34:
Command [java -jar E:/progs/LanguageTool-2.6/languagetool-commandline.jar -c utf-8 - d WHITESPACE_RULE, EN_QUOTES -l pl --api E:/temp/tmp-lt.txt 2> E:/tmp/tmp-lterr.txt] failed with error: 2

So looks like it’s not about temp files location :frowning:
This is driving me crazy

Update: I tried with “minimalistic windows” (in safe mode; no firewall, antywirus, etc) and got the same error.