From 33f7fc001f3eebab1b32b67fbc45d3dbb0b78924 Mon Sep 17 00:00:00 2001 From: matze-dd <45763831+matze-dd@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:32:34 +0200 Subject: [PATCH 01/10] Added vimtex compiler vlty --- compiler/vlty.vim | 115 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 compiler/vlty.vim diff --git a/compiler/vlty.vim b/compiler/vlty.vim new file mode 100644 index 0000000000..22b1fc7c50 --- /dev/null +++ b/compiler/vlty.vim @@ -0,0 +1,115 @@ +" +" vlty: a "compiler" for vimtex, +" invokes LanguageTool with YaLafi as LaTeX filter +" + +if exists("current_compiler") + finish +endif +let current_compiler = "vlty" + +" older Vim always used :setlocal +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal +endif + +let s:cpo_save = &cpo +set cpo&vim + + +" set default values +" +let s:pref = 'In order to use the vlty compiler, please ' +if !exists('g:vimtex_vlty') + let g:vimtex_lty = {} +elseif type(g:vimtex_vlty) != type({}) + echoerr s:pref . 'initialise g:vimtex_vlty with a dictionary.' + finish +endif +let s:vlty = g:vimtex_vlty + +if !has_key(s:vlty, 'ltdirectory') + let s:vlty['ltdirectory'] = '~/lib/LanguageTool' +endif +if !has_key(s:vlty, 'server') + let s:vlty['server'] = '' +endif +if !has_key(s:vlty, 'disable') + let s:vlty['disable'] = 'WHITESPACE_RULE' +endif +if !has_key(s:vlty, 'enable') + let s:vlty['enable'] = '' +endif +if !has_key(s:vlty, 'disablecategories') + let s:vlty['disablecategories'] = '' +endif +if !has_key(s:vlty, 'enablecategories') + let s:vlty['enablecategories'] = '' +endif +if !has_key(s:vlty, 'shell_options') + let s:vlty['shell_options'] = '' +endif +if !has_key(s:vlty, 'show_suggestions') + let s:vlty['show_suggestions'] = 0 +endif + + +" check installation components +" +if !executable('python') + echoerr s:pref . 'install Python.' + finish +endif +call system('python -c "import yalafi"') +if v:shell_error != 0 + echoerr s:pref . 'install the Python module YaLafi.' + finish +endif +if s:vlty['server'] != 'lt' + if !executable('java') + echoerr s:pref . 'install Java.' + finish + endif + if !filereadable(fnamemodify(s:vlty['ltdirectory'] + \ . '/languagetool-commandline.jar', ':p')) + echoerr s:pref . "set g:vimtex_vlty['ltdirectory'] to the" + \ . ' path of LanguageTool.' + finish + endif +endif + + +let s:vimtex = getbufvar(bufnr(), 'vimtex', + \ {'documentclass': '', 'packages': {}}) +let s:documentclass = s:vimtex['documentclass'] +let s:packages = join(keys(s:vimtex['packages']), ',') +let s:language = matchstr(&spelllang, '\v^\a\a([-_]\a\a)?') +let s:language = substitute(s:language, '_', '-', '') + +let &l:makeprg = + \ 'python -m yalafi.shell' + \ . ' --lt-directory ' . s:vlty['ltdirectory'] + \ . (s:vlty['server'] == '' ? '' : ' --server ' . s:vlty['server']) + \ . ' --language ' . s:language + \ . ' --disable "' . s:vlty['disable'] . '"' + \ . ' --enable "' . s:vlty['enable'] . '"' + \ . ' --disablecategories "' . s:vlty['disablecategories'] . '"' + \ . ' --enablecategories "' . s:vlty['enablecategories'] . '"' + \ . ' --documentclass "' . s:documentclass . '"' + \ . ' --packages "' . s:packages . '"' + \ . ' ' . s:vlty['shell_options'] + \ . ' %:S' + +let &l:errorformat = '%A%*\d.) Line %l\, column %v\, Rule ID:%.%#,' +if s:vlty['show_suggestions'] == 0 + let &l:errorformat .= '%ZMessage: %m,%-G%.%#' +else + let &l:errorformat .= '%CMessage: %m,%Z%m,%-G%.%#' +endif + +silent CompilerSet makeprg +silent CompilerSet errorformat + +let &cpo = s:cpo_save +unlet s:cpo_save + From 8a51d9e1f85793739af23f8d98a85b7f770ea23e Mon Sep 17 00:00:00 2001 From: matze-dd <45763831+matze-dd@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:33:30 +0200 Subject: [PATCH 02/10] Added documentation for compiler vlty --- doc/vimtex.txt | 87 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 5 deletions(-) diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 11ffabe60a..0a1afa6ff4 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -2620,6 +2620,9 @@ OPTIONS *vimtex-options* Default value: 1 +*g:vimtex_vlty* + This option configures the |vimtex| compiler `vlty`, see |compiler-vlty|. + ------------------------------------------------------------------------------ COMMANDS *vimtex-commands* @@ -4038,11 +4041,11 @@ Finally, for more full-fledged linting in Vim, see the plug-ins mentioned in ============================================================================== GRAMMAR CHECKING *vimtex-grammar* -|vimtex| provides grammar checking for TeX files through two compilers: -`style-check` [1] and `textidote` [2]. These may be activated with the -|:compiler| command, see |compiler-select|. A selected compiler may then be -used e.g. with |:make| or |:lmake|. See |vimtex-lint| above for some tips on -how to use this feature. +|vimtex| provides grammar checking for TeX files through the compilers +`style-check` [1], `textidote` [2] and `vlty` (see |compiler-vlty|). +These may be activated with the |:compiler| command, see |compiler-select|. +A selected compiler may then be used e.g. with |:make| or |:lmake|. +See |vimtex-lint| above for some tips on how to use this feature. A common workflow is to utilize the |location-list| with |:lmake|: @@ -4050,6 +4053,8 @@ A common workflow is to utilize the |location-list| with |:lmake|: `:compiler style|lmake` - To check the currently open TeX file with `textidote`, run `:compiler textidote|lmake` + - To check the currently open TeX file with `vlty`, run + `:compiler vlty|lmake` The language of the Tex file is determined by |'spelllang'|. Be aware that to use `textidote`, the path to its jar file `textidote.jar` must be indicated in @@ -4058,6 +4063,78 @@ the option |g:vimtex_textidote_jar|. [1] http://www.cs.umd.edu/~nspring/software/style-check-readme.html [2] https://sylvainhalle.github.io/textidote/ +------------------------------------------------------------------------------ +COMPILER VLTY *compiler-vlty* + +The compiler `vlty` invokes the proofreading software `LanguageTool` [1], +applying Python package `YaLafi` [5] for the extraction of plain text. + +In order to use this compiler, you need local installations of both components. +An archive of `LanguageTool` can be downloaded from [2]. After uncompressing +at a suitable place, the path to it is specified as shown below. `YaLafi` can +be installed with `pip install --user yalafi`. + +Configuration is controlled by the Vim dictionary `g:vimtex_vlty` and +|'spelllang'|. As a minimal example, one could write in |vimrc|: > + + let g:vimtex_vlty = {'ltdirectory': 'path/to/LanguageTool'} + set spellang=en_gb + +The given directory has to contain the `LanguageTool` software, including for +instance the file `languagetool-server.jar`. Note that spell checking by +`LanguageTool` is only enabled, if a country code is specified in +|'spelllang'|. + +Default value for `g:vimtex_vlty`: > + + let g:vimtex_vlty = { + \ 'ltdirectory': '~/lib/LanguageTool', + \ 'server': '', + \ 'disable': 'WHITESPACE_RULE', + \ 'enable': '', + \ 'disablecategories': '', + \ 'enablecategories': '', + \ 'shell_options': '', + \ 'show_suggestions': 0, + \} + +The default value shows which entries may be changed. Here the different +keys are explained in more detail: + + ltdirectory~ + Sets the path to the `LanguageTool` software. + + server~ + Specifies, whether an HTTP server should be used. This may be faster + for short texts. Possible values are: + + `` Do not use a server. + `my` Use a local `LanguageTool` server. If not yet running, it is started. + `lt` Contact the Web server provided by `LanguageTool`. In this case, + no local installation is necessary. Please note [3] for conditions + and restrictions. + + disable~ + enable~ + disablecategories~ + enablecategories~ + Options for `LanguageTool` that control application of rules and rule + categories; see [4]. + + shell_options~ + Pass additional options to `YaLafi`, e.g., `--equation-punctuation displ`; + compare [5]. + + show_suggestions~ + If set to 1, then `LanguageTool's` replacement suggestions are included + into the |quickfix| messages. + +[1] https://www.languagetool.org +[2] https://www.languagetool.org/download +[3] http://wiki.languagetool.org/public-http-api +[4] http://wiki.languagetool.org/command-line-options +[5] https://github.com/matze-dd/YaLafi + ============================================================================== VIEW *vimtex-view* From f188769959f6b87c91a32a7c68fbe3eea71300a9 Mon Sep 17 00:00:00 2001 From: matze-dd <45763831+matze-dd@users.noreply.github.com> Date: Thu, 4 Jun 2020 21:12:01 +0200 Subject: [PATCH 03/10] Changed default server entry to 'no'; fixed bug --- compiler/vlty.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/vlty.vim b/compiler/vlty.vim index 22b1fc7c50..bca1aefeb4 100644 --- a/compiler/vlty.vim +++ b/compiler/vlty.vim @@ -21,7 +21,7 @@ set cpo&vim " let s:pref = 'In order to use the vlty compiler, please ' if !exists('g:vimtex_vlty') - let g:vimtex_lty = {} + let g:vimtex_vlty = {} elseif type(g:vimtex_vlty) != type({}) echoerr s:pref . 'initialise g:vimtex_vlty with a dictionary.' finish @@ -32,7 +32,7 @@ if !has_key(s:vlty, 'ltdirectory') let s:vlty['ltdirectory'] = '~/lib/LanguageTool' endif if !has_key(s:vlty, 'server') - let s:vlty['server'] = '' + let s:vlty['server'] = 'no' endif if !has_key(s:vlty, 'disable') let s:vlty['disable'] = 'WHITESPACE_RULE' @@ -89,7 +89,7 @@ let s:language = substitute(s:language, '_', '-', '') let &l:makeprg = \ 'python -m yalafi.shell' \ . ' --lt-directory ' . s:vlty['ltdirectory'] - \ . (s:vlty['server'] == '' ? '' : ' --server ' . s:vlty['server']) + \ . (s:vlty['server'] == 'no' ? '' : ' --server ' . s:vlty['server']) \ . ' --language ' . s:language \ . ' --disable "' . s:vlty['disable'] . '"' \ . ' --enable "' . s:vlty['enable'] . '"' From 172aeff592285d98abd2a36e2ca96db9da8d6576 Mon Sep 17 00:00:00 2001 From: matze-dd <45763831+matze-dd@users.noreply.github.com> Date: Thu, 4 Jun 2020 21:14:55 +0200 Subject: [PATCH 04/10] Default server: 'no'; changed tag *compiler-vlty* --- doc/vimtex.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 0a1afa6ff4..aa4d5a01d1 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -2621,7 +2621,7 @@ OPTIONS *vimtex-options* Default value: 1 *g:vimtex_vlty* - This option configures the |vimtex| compiler `vlty`, see |compiler-vlty|. + This option configures the |vimtex| compiler `vlty`, see |vimtex-vlty|. ------------------------------------------------------------------------------ COMMANDS *vimtex-commands* @@ -4042,7 +4042,7 @@ Finally, for more full-fledged linting in Vim, see the plug-ins mentioned in GRAMMAR CHECKING *vimtex-grammar* |vimtex| provides grammar checking for TeX files through the compilers -`style-check` [1], `textidote` [2] and `vlty` (see |compiler-vlty|). +`style-check` [1], `textidote` [2] and `vlty` (see |vimtex-vlty|). These may be activated with the |:compiler| command, see |compiler-select|. A selected compiler may then be used e.g. with |:make| or |:lmake|. See |vimtex-lint| above for some tips on how to use this feature. @@ -4064,7 +4064,7 @@ the option |g:vimtex_textidote_jar|. [2] https://sylvainhalle.github.io/textidote/ ------------------------------------------------------------------------------ -COMPILER VLTY *compiler-vlty* +COMPILER VLTY *vimtex-vlty* The compiler `vlty` invokes the proofreading software `LanguageTool` [1], applying Python package `YaLafi` [5] for the extraction of plain text. @@ -4089,7 +4089,7 @@ Default value for `g:vimtex_vlty`: > let g:vimtex_vlty = { \ 'ltdirectory': '~/lib/LanguageTool', - \ 'server': '', + \ 'server': 'no', \ 'disable': 'WHITESPACE_RULE', \ 'enable': '', \ 'disablecategories': '', @@ -4108,7 +4108,7 @@ keys are explained in more detail: Specifies, whether an HTTP server should be used. This may be faster for short texts. Possible values are: - `` Do not use a server. + `no` Do not use a server. `my` Use a local `LanguageTool` server. If not yet running, it is started. `lt` Contact the Web server provided by `LanguageTool`. In this case, no local installation is necessary. Please note [3] for conditions From 4ede0b9bccfec36b614a01408033c2fdf2c140a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Sat, 20 Jun 2020 19:00:39 +0200 Subject: [PATCH 05/10] chore: apply suggestions after review --- autoload/vimtex.vim | 11 +++ compiler/vlty.vim | 129 +++++++++++---------------------- doc/vimtex.txt | 170 +++++++++++++++++++++++--------------------- 3 files changed, 140 insertions(+), 170 deletions(-) diff --git a/autoload/vimtex.vim b/autoload/vimtex.vim index d4ba6383b8..3fc7ec4e47 100644 --- a/autoload/vimtex.vim +++ b/autoload/vimtex.vim @@ -126,6 +126,17 @@ function! vimtex#init_options() abort " {{{1 call s:init_option('vimtex_format_enabled', 0) + call s:init_option('vimtex_grammar_vlty', { + \ 'lt_directory': '~/lib/LanguageTool', + \ 'lt_disable': 'WHITESPACE_RULE', + \ 'lt_enable': '', + \ 'lt_disablecategories': '', + \ 'lt_enablecategories': '', + \ 'server': 'no', + \ 'shell_options': '', + \ 'show_suggestions': 0, + \}) + call s:init_option('vimtex_imaps_enabled', 1) call s:init_option('vimtex_imaps_disabled', []) call s:init_option('vimtex_imaps_list', [ diff --git a/compiler/vlty.vim b/compiler/vlty.vim index bca1aefeb4..2cbe333ee1 100644 --- a/compiler/vlty.vim +++ b/compiler/vlty.vim @@ -1,115 +1,70 @@ -" -" vlty: a "compiler" for vimtex, -" invokes LanguageTool with YaLafi as LaTeX filter -" +if exists('current_compiler') | finish | endif +let current_compiler = 'vlty' -if exists("current_compiler") - finish -endif -let current_compiler = "vlty" - -" older Vim always used :setlocal +" Older Vim always used :setlocal if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal + command -nargs=* CompilerSet setlocal endif let s:cpo_save = &cpo set cpo&vim +let s:vlty = g:vimtex_grammar_vlty -" set default values -" -let s:pref = 'In order to use the vlty compiler, please ' -if !exists('g:vimtex_vlty') - let g:vimtex_vlty = {} -elseif type(g:vimtex_vlty) != type({}) - echoerr s:pref . 'initialise g:vimtex_vlty with a dictionary.' - finish +if !executable('python') + call vimtex#log#error('vlty compiler requires Python') + finish endif -let s:vlty = g:vimtex_vlty -if !has_key(s:vlty, 'ltdirectory') - let s:vlty['ltdirectory'] = '~/lib/LanguageTool' -endif -if !has_key(s:vlty, 'server') - let s:vlty['server'] = 'no' -endif -if !has_key(s:vlty, 'disable') - let s:vlty['disable'] = 'WHITESPACE_RULE' -endif -if !has_key(s:vlty, 'enable') - let s:vlty['enable'] = '' -endif -if !has_key(s:vlty, 'disablecategories') - let s:vlty['disablecategories'] = '' -endif -if !has_key(s:vlty, 'enablecategories') - let s:vlty['enablecategories'] = '' -endif -if !has_key(s:vlty, 'shell_options') - let s:vlty['shell_options'] = '' -endif -if !has_key(s:vlty, 'show_suggestions') - let s:vlty['show_suggestions'] = 0 +call system('python -c "import yalafi"') +if v:shell_error != 0 + call vimtex#log#error('vlty compiler requires the Python module YaLafi') + finish endif - -" check installation components -" -if !executable('python') - echoerr s:pref . 'install Python.' +if s:vlty.server !=# 'lt' + if !executable('java') + call vimtex#log#error('vlty compiler requires java') finish -endif -call system('python -c "import yalafi"') -if v:shell_error != 0 - echoerr s:pref . 'install the Python module YaLafi.' + endif + + if !filereadable(fnamemodify(s:vlty.lt_directory + \ . '/languagetool-commandline.jar', ':p')) + call vimtex#log#error('vlty compiler - lt_directory path not valid') finish + endif endif -if s:vlty['server'] != 'lt' - if !executable('java') - echoerr s:pref . 'install Java.' - finish - endif - if !filereadable(fnamemodify(s:vlty['ltdirectory'] - \ . '/languagetool-commandline.jar', ':p')) - echoerr s:pref . "set g:vimtex_vlty['ltdirectory'] to the" - \ . ' path of LanguageTool.' - finish - endif -endif - -let s:vimtex = getbufvar(bufnr(), 'vimtex', - \ {'documentclass': '', 'packages': {}}) -let s:documentclass = s:vimtex['documentclass'] -let s:packages = join(keys(s:vimtex['packages']), ',') +let s:vimtex = get(b:, 'vimtex', {'documentclass': '', 'packages': {}}) +let s:documentclass = s:vimtex.documentclass +let s:packages = join(keys(s:vimtex.packages), ',') let s:language = matchstr(&spelllang, '\v^\a\a([-_]\a\a)?') let s:language = substitute(s:language, '_', '-', '') let &l:makeprg = - \ 'python -m yalafi.shell' - \ . ' --lt-directory ' . s:vlty['ltdirectory'] - \ . (s:vlty['server'] == 'no' ? '' : ' --server ' . s:vlty['server']) - \ . ' --language ' . s:language - \ . ' --disable "' . s:vlty['disable'] . '"' - \ . ' --enable "' . s:vlty['enable'] . '"' - \ . ' --disablecategories "' . s:vlty['disablecategories'] . '"' - \ . ' --enablecategories "' . s:vlty['enablecategories'] . '"' - \ . ' --documentclass "' . s:documentclass . '"' - \ . ' --packages "' . s:packages . '"' - \ . ' ' . s:vlty['shell_options'] - \ . ' %:S' + \ 'python -m yalafi.shell' + \ . ' --lt-directory ' . s:vlty.lt_directory + \ . (s:vlty.server ==# 'no' + \ ? '' + \ : ' --server ' . s:vlty.server) + \ . ' --language ' . s:language + \ . ' --disable "' . s:vlty.lt_disable . '"' + \ . ' --enable "' . s:vlty.lt_enable . '"' + \ . ' --disablecategories "' . s:vlty.lt_disablecategories . '"' + \ . ' --enablecategories "' . s:vlty.lt_enablecategories . '"' + \ . ' --documentclass "' . s:documentclass . '"' + \ . ' --packages "' . s:packages . '"' + \ . ' ' . s:vlty.shell_options + \ . ' %:S' +silent CompilerSet makeprg let &l:errorformat = '%A%*\d.) Line %l\, column %v\, Rule ID:%.%#,' -if s:vlty['show_suggestions'] == 0 - let &l:errorformat .= '%ZMessage: %m,%-G%.%#' +if s:vlty.show_suggestions == 0 + let &l:errorformat .= '%ZMessage: %m,%-G%.%#' else - let &l:errorformat .= '%CMessage: %m,%Z%m,%-G%.%#' + let &l:errorformat .= '%CMessage: %m,%Z%m,%-G%.%#' endif - -silent CompilerSet makeprg silent CompilerSet errorformat let &cpo = s:cpo_save unlet s:cpo_save - diff --git a/doc/vimtex.txt b/doc/vimtex.txt index aa4d5a01d1..a0aa28fc54 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -78,6 +78,7 @@ CONTENTS *vimtex-contents* Arara |vimtex-arara| Syntax Checking (Linting) |vimtex-lint| Grammar Checking |vimtex-grammar| + vlty |vimtex-grammar-vlty| View |vimtex-view| Synctex |vimtex-synctex| Forward search |vimtex-synctex-forward-search| @@ -1641,6 +1642,54 @@ OPTIONS *vimtex-options* Default value: 0 +*g:vimtex_grammar_vlty* + This option is used to configure the `vlty` grammar checker. It is a dictionary + with the following keys (see |vimtex-grammar-vlty| for more details): + + lt_directory~ + Path to the `LanguageTool` software. + + lt_disable~ + lt_enable~ + disablecategories~ + enablecategories~ + Options for `LanguageTool` that control application of rules and rule + categories. For more info, see: + http://wiki.languagetool.org/command-line-options + + server~ + Specify whether an HTTP server should be used. This may be faster for + short texts. Possible values are: + + `no` Do not use a server. + `my` Use a local `LanguageTool` server. If not yet running, it is started. + `lt` Contact the Web server provided by `LanguageTool`. In this case, + no local installation is necessary. Please see the following page + for conditions and restrictions: + http://wiki.languagetool.org/public-http-api + + shell_options~ + Pass additional options to `YaLafi`, e.g., `--equation-punctuation displ`; + for more info, see: + https://github.com/matze-dd/YaLafi + + show_suggestions~ + If set to 1, then `LanguageTool's` replacement suggestions are included + in the |quickfix| or |location-list| messages. + + Default: > + + let g:vimtex_grammar_vlty = { + \ 'lt_directory': '~/lib/LanguageTool', + \ 'lt_disable': 'WHITESPACE_RULE', + \ 'lt_enable': '', + \ 'lt_disablecategories': '', + \ 'lt_enablecategories': '', + \ 'server': 'no', + \ 'shell_options': '', + \ 'show_suggestions': 0, + \} + *g:vimtex_imaps_enabled* Use this option to disable/enable the insert mode mappings. @@ -2620,9 +2669,6 @@ OPTIONS *vimtex-options* Default value: 1 -*g:vimtex_vlty* - This option configures the |vimtex| compiler `vlty`, see |vimtex-vlty|. - ------------------------------------------------------------------------------ COMMANDS *vimtex-commands* @@ -4041,99 +4087,57 @@ Finally, for more full-fledged linting in Vim, see the plug-ins mentioned in ============================================================================== GRAMMAR CHECKING *vimtex-grammar* -|vimtex| provides grammar checking for TeX files through the compilers -`style-check` [1], `textidote` [2] and `vlty` (see |vimtex-vlty|). -These may be activated with the |:compiler| command, see |compiler-select|. -A selected compiler may then be used e.g. with |:make| or |:lmake|. -See |vimtex-lint| above for some tips on how to use this feature. +|vimtex| provides grammar checking for TeX files through the |compiler-select| +feature in Vim for a few selected checkers. They may be activated with the +|:compiler| command. A selected compiler may then be used e.g. with |:make| or +|:lmake|. The language of the Tex file is determined by |'spelllang'|. As an +example, one may do the following to use the |location-list| with a given +checker: > -A common workflow is to utilize the |location-list| with |:lmake|: + :compiler {checker}|lmake - - To check the currently open TeX file with `style-check`, run - `:compiler style|lmake` - - To check the currently open TeX file with `textidote`, run - `:compiler textidote|lmake` - - To check the currently open TeX file with `vlty`, run - `:compiler vlty|lmake` +See also |vimtex-lint| above for some tips on how to use this feature. The +following is a list of the available checkers: -The language of the Tex file is determined by |'spelllang'|. Be aware that to -use `textidote`, the path to its jar file `textidote.jar` must be indicated in -the option |g:vimtex_textidote_jar|. + style-check~ + http://www.cs.umd.edu/~nspring/software/style-check-readme.html -[1] http://www.cs.umd.edu/~nspring/software/style-check-readme.html -[2] https://sylvainhalle.github.io/textidote/ + textidote~ + https://sylvainhalle.github.io/textidote/ + To use `textidote`, the path to its jar file `textidote.jar` must be + indicated in the option |g:vimtex_textidote_jar|. + vlty~ + See more details here: |vimtex-grammar-vlty| +> ------------------------------------------------------------------------------ -COMPILER VLTY *vimtex-vlty* +VLTY *vimtex-grammar-vlty* -The compiler `vlty` invokes the proofreading software `LanguageTool` [1], -applying Python package `YaLafi` [5] for the extraction of plain text. +The `vlty` compiler uses the Python package `YaLafi` [1] for extracting the +plain text and combines this with the proofreading software `LanguageTool` [2]. -In order to use this compiler, you need local installations of both components. -An archive of `LanguageTool` can be downloaded from [2]. After uncompressing -at a suitable place, the path to it is specified as shown below. `YaLafi` can -be installed with `pip install --user yalafi`. +In order to use `vlty`, you need local installations of both components. An +archive of `LanguageTool` can be downloaded from [3]. After uncompressing at +a suitable place, the path to it is specified as shown below. `YaLafi` itself +can be installed with: > -Configuration is controlled by the Vim dictionary `g:vimtex_vlty` and -|'spelllang'|. As a minimal example, one could write in |vimrc|: > + pip install --user yalafi - let g:vimtex_vlty = {'ltdirectory': 'path/to/LanguageTool'} +Configuration is controlled by the Vim dictionary |g:vimtex_grammar_vlty|. +As a minimal example, one could write in |vimrc|: > + + let g:vimtex_grammar_vlty = {'lt_directory': 'path/to/LanguageTool'} set spellang=en_gb The given directory has to contain the `LanguageTool` software, including for -instance the file `languagetool-server.jar`. Note that spell checking by -`LanguageTool` is only enabled, if a country code is specified in -|'spelllang'|. - -Default value for `g:vimtex_vlty`: > - - let g:vimtex_vlty = { - \ 'ltdirectory': '~/lib/LanguageTool', - \ 'server': 'no', - \ 'disable': 'WHITESPACE_RULE', - \ 'enable': '', - \ 'disablecategories': '', - \ 'enablecategories': '', - \ 'shell_options': '', - \ 'show_suggestions': 0, - \} - -The default value shows which entries may be changed. Here the different -keys are explained in more detail: - - ltdirectory~ - Sets the path to the `LanguageTool` software. - - server~ - Specifies, whether an HTTP server should be used. This may be faster - for short texts. Possible values are: - - `no` Do not use a server. - `my` Use a local `LanguageTool` server. If not yet running, it is started. - `lt` Contact the Web server provided by `LanguageTool`. In this case, - no local installation is necessary. Please note [3] for conditions - and restrictions. - - disable~ - enable~ - disablecategories~ - enablecategories~ - Options for `LanguageTool` that control application of rules and rule - categories; see [4]. - - shell_options~ - Pass additional options to `YaLafi`, e.g., `--equation-punctuation displ`; - compare [5]. - - show_suggestions~ - If set to 1, then `LanguageTool's` replacement suggestions are included - into the |quickfix| messages. - -[1] https://www.languagetool.org -[2] https://www.languagetool.org/download -[3] http://wiki.languagetool.org/public-http-api -[4] http://wiki.languagetool.org/command-line-options -[5] https://github.com/matze-dd/YaLafi +instance the file `languagetool-server.jar`. + +Note: Spell checking with `LanguageTool` is only enabled if a country code is + specified in |'spelllang'|. + +[1] https://github.com/matze-dd/YaLafi +[2] https://www.languagetool.org +[3] https://www.languagetool.org/download ============================================================================== VIEW *vimtex-view* From c481ac02f48cf7120b7d12a016f8b292c22929e6 Mon Sep 17 00:00:00 2001 From: matze-dd <45763831+matze-dd@users.noreply.github.com> Date: Tue, 23 Jun 2020 11:28:47 +0200 Subject: [PATCH 06/10] Corrected typos --- doc/vimtex.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/vimtex.txt b/doc/vimtex.txt index a0aa28fc54..4b7c27d6f1 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -1651,8 +1651,8 @@ OPTIONS *vimtex-options* lt_disable~ lt_enable~ - disablecategories~ - enablecategories~ + lt_disablecategories~ + lt_enablecategories~ Options for `LanguageTool` that control application of rules and rule categories. For more info, see: http://wiki.languagetool.org/command-line-options @@ -4127,7 +4127,7 @@ Configuration is controlled by the Vim dictionary |g:vimtex_grammar_vlty|. As a minimal example, one could write in |vimrc|: > let g:vimtex_grammar_vlty = {'lt_directory': 'path/to/LanguageTool'} - set spellang=en_gb + set spelllang=en_gb The given directory has to contain the `LanguageTool` software, including for instance the file `languagetool-server.jar`. From 78b9c61f70d07896dd1925fd493d325bc9bc09ad Mon Sep 17 00:00:00 2001 From: matze-dd <45763831+matze-dd@users.noreply.github.com> Date: Tue, 23 Jun 2020 11:48:47 +0200 Subject: [PATCH 07/10] Direct error message to user on failed installation test --- compiler/vlty.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/vlty.vim b/compiler/vlty.vim index 2cbe333ee1..8c03d3ae22 100644 --- a/compiler/vlty.vim +++ b/compiler/vlty.vim @@ -13,24 +13,28 @@ let s:vlty = g:vimtex_grammar_vlty if !executable('python') call vimtex#log#error('vlty compiler requires Python') + echoerr 'vlty compiler requires Python' finish endif call system('python -c "import yalafi"') if v:shell_error != 0 call vimtex#log#error('vlty compiler requires the Python module YaLafi') + echoerr 'vlty compiler requires the Python module YaLafi' finish endif if s:vlty.server !=# 'lt' if !executable('java') call vimtex#log#error('vlty compiler requires java') + echoerr 'vlty compiler requires java' finish endif if !filereadable(fnamemodify(s:vlty.lt_directory \ . '/languagetool-commandline.jar', ':p')) call vimtex#log#error('vlty compiler - lt_directory path not valid') + echoerr 'vlty compiler - lt_directory path not valid' finish endif endif From 0740cd0b4d635d7d6f66d424c2cfeb7e99a1c5e2 Mon Sep 17 00:00:00 2001 From: matze-dd <45763831+matze-dd@users.noreply.github.com> Date: Wed, 24 Jun 2020 11:39:29 +0200 Subject: [PATCH 08/10] Changed installation error messages --- compiler/vlty.vim | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/vlty.vim b/compiler/vlty.vim index 8c03d3ae22..e1b80a90c0 100644 --- a/compiler/vlty.vim +++ b/compiler/vlty.vim @@ -11,30 +11,31 @@ set cpo&vim let s:vlty = g:vimtex_grammar_vlty +function! s:installation_error(msg) + call vimtex#log#error( + \ [a:msg, 'Please see ":help vimtex-grammar-vlty" for more details.']) +endfunction + if !executable('python') - call vimtex#log#error('vlty compiler requires Python') - echoerr 'vlty compiler requires Python' + call s:installation_error('vlty compiler requires Python') finish endif call system('python -c "import yalafi"') if v:shell_error != 0 - call vimtex#log#error('vlty compiler requires the Python module YaLafi') - echoerr 'vlty compiler requires the Python module YaLafi' + call s:installation_error('vlty compiler requires the Python module YaLafi') finish endif if s:vlty.server !=# 'lt' if !executable('java') - call vimtex#log#error('vlty compiler requires java') - echoerr 'vlty compiler requires java' + call s:installation_error('vlty compiler requires java') finish endif if !filereadable(fnamemodify(s:vlty.lt_directory \ . '/languagetool-commandline.jar', ':p')) - call vimtex#log#error('vlty compiler - lt_directory path not valid') - echoerr 'vlty compiler - lt_directory path not valid' + call s:installation_error('vlty compiler - lt_directory path not valid') finish endif endif From e7fb8f0fa6d08aad91ac278dc62ef020444b433a Mon Sep 17 00:00:00 2001 From: matze-dd <45763831+matze-dd@users.noreply.github.com> Date: Thu, 25 Jun 2020 08:01:10 +0200 Subject: [PATCH 09/10] Added remark for test of vlty installation --- doc/vimtex.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 4b7c27d6f1..4bf2bb4889 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -4130,7 +4130,8 @@ As a minimal example, one could write in |vimrc|: > set spelllang=en_gb The given directory has to contain the `LanguageTool` software, including for -instance the file `languagetool-server.jar`. +instance the file `languagetool-server.jar`. A separated `:compiler vlty` will +raise an error message, if some component cannot be found. Note: Spell checking with `LanguageTool` is only enabled if a country code is specified in |'spelllang'|. From 69d9c3c0b131c91a90828a38d63610546dc4bb49 Mon Sep 17 00:00:00 2001 From: matze-dd <45763831+matze-dd@users.noreply.github.com> Date: Wed, 15 Jul 2020 14:02:16 +0200 Subject: [PATCH 10/10] Added file name to errorformat --- compiler/vlty.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/vlty.vim b/compiler/vlty.vim index e1b80a90c0..0e99025ccc 100644 --- a/compiler/vlty.vim +++ b/compiler/vlty.vim @@ -63,7 +63,7 @@ let &l:makeprg = \ . ' %:S' silent CompilerSet makeprg -let &l:errorformat = '%A%*\d.) Line %l\, column %v\, Rule ID:%.%#,' +let &l:errorformat = '%I=== %f ===,%C%*\d.) Line %l\, column %v\, Rule ID:%.%#,' if s:vlty.show_suggestions == 0 let &l:errorformat .= '%ZMessage: %m,%-G%.%#' else