Skip to content

Commit

Permalink
Print stderr output of LanguageTool command if it fails to help
Browse files Browse the repository at this point in the history
diagnose why LanguageTool command line may fail.
  • Loading branch information
dpelle committed Dec 7, 2013
1 parent 0977c42 commit ef5f42d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plugin/LanguageTool.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
" Maintainer: Dominique Pellé <[email protected]>
" Screenshots: http://dominique.pelle.free.fr/pic/LanguageToolVimPlugin_en.png
" http://dominique.pelle.free.fr/pic/LanguageToolVimPlugin_fr.png
" Last Change: 2013/08/10
" Version: 1.25
" Last Change: 2013/10/24
" Version: 1.27
"
" Long Description: {{{1
"
Expand Down Expand Up @@ -230,6 +230,7 @@ function s:LanguageToolCheck(line1, line2) "{{{1
" reading from stdin so we need to use a temporary file to get
" correct results.
let l:tmpfilename = tempname()
let l:tmperror = tempname()

let l:range = a:line1 . ',' . a:line2
silent exe l:range . 'w!' . l:tmpfilename
Expand All @@ -240,16 +241,22 @@ function s:LanguageToolCheck(line1, line2) "{{{1
\ . ' -d ' . s:languagetool_disable_rules
\ . ' -l ' . s:languagetool_lang
\ . ' --api ' . l:tmpfilename
\ . ' 2> ' . l:tmperror

sil exe '%!' . l:languagetool_cmd
call delete(l:tmpfilename)

if v:shell_error
echoerr 'Command [' . l:languagetool_cmd . '] failed with error: '
\ . v:shell_error
if filereadable(l:tmperror)
echoerr string(readfile(l:tmperror))
endif
call delete(l:tmperror)
call s:LanguageToolClear()
return -1
endif
call delete(l:tmperror)

" Loop on all errors in XML output of LanguageTool and
" collect information about all errors in list s:errors
Expand Down

0 comments on commit ef5f42d

Please sign in to comment.